简体   繁体   English

File.Create使用错误的路径名

[英]File.Create taking wrong path name

I have used this before in Windows XP and VS2008 and never got this error now using VS 2012 and windows 8. 我以前在Windows XP和VS2008中使用过此功能,现在在VS 2012和Windows 8中从未遇到此错误。

This is my simple code to create a file in c drive is giving exception 这是我在c驱动器中创建文件的简单代码,给出了异常

string path = @"C\SaveValues.txt";
if (!File.Exists(path))
{
    using (File.Create(path))
    {
    }
}

Could not find a part of the path 'C:\\Program Files (x86)\\IIS Express\\C\\SaveValues.txt'. 找不到路径“ C:\\ Program Files(x86)\\ IIS Express \\ C \\ SaveValues.txt”的一部分。

What is this error referring to? 该错误指的是什么?

Change it to 更改为

string path=@"C:\\SaveValues.txt"; (mainly look at C: ) (主要看C:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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