Home All Groups Group Topic Archive Search About
Author
24 Aug 2006 8:08 PM
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

Author
24 Aug 2006 8:23 PM
Dave Kreskowiak
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")

--
<i><b>RageInTheMachine9532</b></i><font size="-2">
"<i>...a pungent, ghastly, stinky piece of cheese!</i>" <b>-- The Roaming
Gnome</b></font>


Show quoteHide quote
"Matt" wrote:

> 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
>
>
>
Author
25 Aug 2006 4:43 PM
Matt
Dave

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

Matt

Show quoteHide quote
"Dave Kreskowiak" <DaveKreskow***@discussions.microsoft.com> wrote in
message news:CF95E0EA-54AB-48D1-A450-1FD9EDA05E5C@microsoft.com...
> 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")
>
> --
> <i><b>RageInTheMachine9532</b></i><font size="-2">
> "<i>...a pungent, ghastly, stinky piece of cheese!</i>" <b>-- The Roaming
> Gnome</b></font>
>
>
> "Matt" wrote:
>
>> 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
>>
>>
>>