SystemRoot

  • Thread starter Thread starter Matt
  • Start date Start date
M

Matt

I'm trying to use SystemRoot or any other directory reference to open a
filestream, but instead I get an error saying that the directory the project
is looking in is the path of the project's bin file with my path appended to
it. Hard-coding the directory works perfectly. Can I use the directory
references to open a filestream? If not, is there another way to do it?

Thanks,
Matt
 
I'm not really sure what you're trying to do. It's always a good idea to
specify complete paths to all files that you use. The trick is in building
the path correctly. If you're trying to get at a file in the directory of
your .EXE, you can use something like this:

Dim filepath As String
filepath = Path.Combine(Application.StartupPath, "myfile.txt")

There are, of course, various default paths, like the users profile path or
the system directory, that you can use to start building other paths, like:

filepath = Path.Combine(Environment.GetFolderPath(SpecialFolder.System,
"myfile.txt")
 
Dave

Actually, the Path and Application commands were exactly what I was looking
for. Thanks for your help!

Matt
 
Back
Top