希望在安装包安装的时候能检测计算机指定位置是否有文件存在,如果有文件存在,就继续安装,如果没有就退回,提示安装无法继续,请问如何实现呢?

解决方案 »

  1.   

    如果是vs中自带的安装打包功能,可以写安装类。在其中IO检查文件是否存在。
      

  2.   

    1.asp.net
     string filepath = Server.MapPath("App_Data");
            string[] file = System.IO.Directory.GetFiles(filepath);
            foreach (string thisFile in file)
            {
                if (System.IO.File.Exists(thisFile) 
    2.c#
     string[] getfile = Directory.GetFiles("c:\\DBfolder");
                  
                    if (getfile.Length == 0)
                    {
                        MessageBox.Show("检查文件夹是否存在或者为空!", "info", MessageBoxButtons.OK ,MessageBoxIcon.Warning );
                    }