Exemple #1
0
        /// <summary>
        /// DataSet输出XML格式文档
        /// </summary>
        /// <param name="filepath">XML文件路径</param>
        public static void WriteDataSetToXml(string filepath)
        {
            DataSet ds = new DataSet();

            EKFile.GetMapPath(filepath);
            //创建XML对象
            XmlTextWriter xml = new XmlTextWriter(filepath, Encoding.Default);

            try
            {
                //设置返回格式
                xml.Formatting  = Formatting.Indented;
                xml.Indentation = 4;//缩进
                xml.IndentChar  = ' ';
                xml.WriteStartDocument();
                //输出XML格式数据 到客户端
                ds.WriteXml(xml);
            }
            catch
            {
            }
            finally
            {
                xml.Flush();
                xml.Close();
            }
        }
Exemple #2
0
        /// <summary>
        /// 删除目录,目录下存在文件.全部删除.但不删除本身目录
        /// </summary>
        /// <param name="Path"></param>
        /// <returns></returns>
        public static int DeleteDirectoryAnd(string Path)
        {
            int fileNum = 0;

            string[] fileList = System.IO.Directory.GetFileSystemEntries(Path);
            // 遍历所有的文件和目录
            foreach (string file in fileList)
            {
                if (System.IO.Directory.Exists(file))
                {
                    DeleteDirectoryAnd(file);
                }
                else
                {
                    fileNum++;
                    EKFile.DeleteFile(file);
                }
            }
            return(fileNum);
        }
Exemple #3
0
 /// <summary>
 /// 打开数据库
 /// </summary>
 private static void openConnection()
 {
     if (conn.State == ConnectionState.Closed)
     {
         string conStr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + EKFile.GetMapPath("/") + ConnectString + ";";
         if (Password == "")
         {
             conStr += "Persist Security Info=False;";
         }
         else
         {
             conStr += "Jet OLEDB:Database PassWord="******"";
         }
         conn.ConnectionString = conStr;
         comm.Connection       = conn;
         try
         {
             conn.Open();
         }
         catch (Exception e)
         { throw new Exception(e.Message); }
     }
 }