Search code examples
streamreader

c# Trying to call a file, filenotfound exception. Is it the VMWare?


  • This is a really beginner question, I'm trying to read a file and write a JSON, but I keep getting "filenotfound" exception in visual studio. I'm using VMWARE windows 10, and I'm confused about how to establish the directory using VMWare. Maybe it's more of a lack of understanding the code itself than how it's effected by the VMWare.

  • Also would like to know cases in which VMware effects a similar situation.

I'm trying to call the folder this way:

const string _data1 = "Data1.txt";   // initilize  

string Filename = @"\\vmware-host\Shared Folders\Desktop\JSONproject";

then futher down the program:

using (StreamReader r = new StreamReader(_data1))
                {
                    string line;
                    while ((line = r.ReadLine()) != null)
                    {
                        Data1.Add(line);        // add to list
                    }
                }
                Console.WriteLine(outputMessage);
                break;

Solution

  • I've come upon this problem. You need to move the file into the C: rather than it be on the desktop. The VMware desktop is shared with the mac, which makes it ambiguous for visual studio to call.