VS2012或者VS2013面向win8开发的代码File类没有,如何写文件?求,重谢
VS2012或者VS2013面向win8开发的代码File类没有,怎么写文件?求高手指点,重谢
VS2012或者VS2013面向win8开发的代码,
System.IO中没有File类没有
怎么写文件?有没有高手指点!
------解决方案--------------------
一直都用FileStream+StreamReader或StreamWriter
------解决方案--------------------
------解决方案--------------------
FileOpen(1, "E:\y.txt", OpenMode.Output)
PrintLine(1, "abc")
PrintLine(1, "123")
FileClose(1)
------解决方案--------------------
和VB2008在win7下是一样的
VS2012或者VS2013面向win8开发的代码,
System.IO中没有File类没有
怎么写文件?有没有高手指点!
------解决方案--------------------
一直都用FileStream+StreamReader或StreamWriter
------解决方案--------------------
string path = Path.GetTempFileName();
FileInfo fi1 = new FileInfo(path);
//Create a file to write to.
using (StreamWriter sw = fi1.CreateText())
{
sw.WriteLine("Hello");
sw.WriteLine("And");
sw.WriteLine("Welcome");
}
//Open the file to read from.
using (StreamReader sr = fi1.OpenText())
{
string s = "";
while ((s = sr.ReadLine()) != null)
{
Console.WriteLine(s);
}
}
try
{
string path2 = Path.GetTempFileName();
FileInfo fi2 = new FileInfo(path2);
//Ensure that the target does not exist.
fi2.Delete();
//Copy the file.
fi1.CopyTo(path2);
Console.WriteLine("{0} was copied to {1}.", path, path2);
//Delete the newly created file.
fi2.Delete();
Console.WriteLine("{0} was successfully deleted.", path2);
}
catch (Exception e)
{
Console.WriteLine("The process failed: {0}", e.ToString());
}
------解决方案--------------------
FileOpen(1, "E:\y.txt", OpenMode.Output)
PrintLine(1, "abc")
PrintLine(1, "123")
FileClose(1)
------解决方案--------------------
和VB2008在win7下是一样的