开发者

trying to write to c:\temp in my console app

开发者 https://www.devze.com 2023-01-01 02:09 出处:网络
I have a very simple console ap开发者_如何转开发p where I\'m using dataset.WriteXml(@\"c:\\temp\")

I have a very simple console ap开发者_如何转开发p where I'm using

dataset.WriteXml(@"c:\temp") 

but I'm getting message "Access Denied". What do I need to do?

Using Visual Studio 2008 on XP Pro.


You're trying to write to "c:\temp" which I suspect is a directory. Try:

dataset.WriteXml(@"c:\temp\dataset.xml")


If you're just trying to create a temporary file, rather than using C:\Temp, which may not be writable depending on user privileges, use Path.GetTempFileName(). This will return a filename in the user's \AppData\Local\Temp directory, which the user can write to.

0

精彩评论

暂无评论...
验证码 换一张
取 消