简体   繁体   中英

create file on localhost (Web server physical path)

Currently I am working on asp.net website and I am not very much familiar with asp.net. I have a WebForm and when user clicks on Submit button a .txt file should be get created on server(Text File name is ID entered by user which is unique.)
I used following to create the file.

File.Create( Server.MapPath("~") + id + @".txt");  

But this gives me error when the site is running on the localhost of my pc.
Access to the path 'C:\\inetpub\\wwwroot\\XXX\\YYY.txt' is denied.

This is something related with access permission. What should I do to fix this. Please advice me.

将NETWORK SERVICE的写入权限添加到相关文件夹。

File.Create(@"\\127.0.0.1\www\test\test.txt");  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM