Hello-World
Hello-World

Reputation: 9545

write to a text file that is in my site

On my local pc I want to write to a text file that is in my site. How do I get the path in vb.net so I don't have to hard code the path. I tried ~\test.txt but it did not work

My.Computer.FileSystem.OpenTextFileWriter("C:\test\mysite\test.txt", True)

''What I want is My.Computer.FileSystem.OpenTextFileWriter( getMysitePath() +  "test.txt", True)

Upvotes: 1

Views: 164

Answers (1)

ekad
ekad

Reputation: 14614

Use Server.MapPath method, with the below example I assume test.txt is in the root folder of your website

My.Computer.FileSystem.OpenTextFileWriter(Server.MapPath("~/test.txt"), True)

Upvotes: 2

Related Questions