VS2012或者VS2013面向win8开发的代码File类没有,怎么写文件?求高手指点,重谢

mlybcao 2014-01-21 03:01:05
VS2012或者VS2013面向win8开发的代码,
System.IO中没有File类没有
怎么写文件?有没有高手指点!
...全文
291 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_29087253 2015-09-27
  • 打赏
  • 举报
回复
加入IO包就行 using System.IO;
hzybc 2014-01-23
  • 打赏
  • 举报
回复
和VB2008在win7下是一样的
hzybc 2014-01-23
  • 打赏
  • 举报
回复
FileOpen(1, "E:\y.txt", OpenMode.Output) PrintLine(1, "abc") PrintLine(1, "123") FileClose(1)
wind_cloud2011 2014-01-21
  • 打赏
  • 举报
回复
 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());
        }
上海什么大学 2014-01-21
  • 打赏
  • 举报
回复
一直都用FileStream+StreamReader或StreamWriter

16,553

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧