zoukankan      html  css  js  c++  java
  • C# 文件操作

    ####文件操作

     1            //检查文件是否存在
     2             File.Exists(@"c:my folderfilename");
     3             try { File.Delete(@"c:jihua.cnblogs.com.txt"); }
     4             catch
     5             {
     6                 MessageBox.Show("删除失败", "jihua.cnblogs.com");
     7             }
     8             try { File.Create(@"c:jihua.cnblogs.com.txt"); }
     9             catch
    10             {
    11                 MessageBox.Show("创建失败", "jihua.cnblogs.com");
    12             }
    13             try { File.Move(@"c:jihua.cnblogs.com.txt", @"c:
    ew.jihua.cnblogs.com.txt"); }
    14             catch
    15             {
    16                 MessageBox.Show("移动失败", "jihua.cnblogs.com");
    17             }
    18             //打开文件
    19             if (Msg.AskQuestion("是否打开文件?"))
    20             {
    21                 System.Diagnostics.Process.Start(filename);
    22             }
    23             

    ####文件夹操作

                bool exists = Directory.Exists(@"c:my folder");//检查文件夹是否存
                try { Directory.Delete(@"c:my folder"); }
                catch
                {
                MessageBox.Show("删除失败", "jihua.cnblogs.com");
                }
                try { Directory.CreateDirectory(@"c:my folder"); }
                catch
                {
                MessageBox.Show("创建失败","jihua.cnblogs.com");
                }
                try { Directory.Move(@"c:my folder",@"d:folder"); }
                catch
                {
                MessageBox.Show("移动失败", "jihua.cnblogs.com");
                }
  • 相关阅读:
    学好VC++的十大良好习惯
    VC6.0调试技巧
    匈牙利命名法
    VC中常用文件操作(三)
    VL_FEAT——图像处理函数库
    MATLAB——linspace
    (Your)((Term)((Project)))(字符串处理)
    Matrix Chain Multiplication(栈的简单应用)
    The Triangle(DP基础)
    MATLAB——polyfit
  • 原文地址:https://www.cnblogs.com/vitas/p/6444319.html
Copyright © 2011-2022 走看看