Click here to Skip to main content
15,922,696 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

When i use filestream we should mention the folder path as below code ("C:\Variables.txt",...)

Dim fs As New FileStream("c:\Variables.txt", FileMode.Append, FileAccess.Write, FileShare.Write.


But, i want to store in without mentiong the drive name anywhere in the created folder.
like filestream("~\LogFile\Variables.txt",.....).

pls. give me the correct syntax for the map path as above.

Thanks.
Posted

Well, you were trying to save the file in absolute path. But if you need to save it relative path, you need to create a folder in your web site or you need to use your root folder of the web site. I put some code snippet that may need to look it.

C++
string path = Server.MapPath("~");// Maps the root web site folder

C++
string path = Server.MapPath("~/LogFile");// Will map a folder name called LogFile in your website.



I hope this will help you well.
 
Share this answer
 
v3
 
Share this answer
 
I suspect the root of your problem is controversy between absolute path and relative path. You need to keep almost all of the absolute path except the volume. This is simply the same as relative path but relative to the volume root.

Using both relative and absolute approached in code is wrong. Please see my recent answer where I explain the idea how to work with file paths:
How to access a file from html folder of root directoty[^].

Hope it can help you.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900