Ejemplo n.º 1
0
        /// <summary>
        /// 删除文件
        /// </summary>
        /// <param name="dirname"></param>
        /// <param name="filename"></param>
        public void DeleteFile(string dirname, string filename)
        {
            using (IdentityScope iss = new IdentityScope(username, hostIp, password))
            {
                string filepath = GetFileName(dirname, filename);

                if (File.Exists(filepath))
                    File.Delete(filepath);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 取得文件
 /// </summary>
 /// <param name="dirname"></param>
 /// <returns></returns>
 public string[] findFile(string dirname)
 {
     using (IdentityScope iss = new IdentityScope(username, hostIp, password))
     {
         //try
         //{
         return System.IO.Directory.GetFiles(@"\\" + hostIp + @"\" + dirname);
         //}
         //catch (Exception e)
         //{
         //    Console.WriteLine(e.Message);
         //}
         //return null;
     }
 }
Ejemplo n.º 3
0
        public void WriteFile(string dirname, string filename, Stream stream)
        {
            using (IdentityScope iss = new IdentityScope(username, hostIp, password))
            {
                string filepath = GetFileName(dirname, filename);

                var path = Path.GetDirectoryName(filepath);

                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                using (StreamWriter sw = new StreamWriter(stream))
                {
                    sw.WriteLine(stream);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 写入指定的文件,如果不存在创建目录并写入文件
        /// </summary>
        /// <param name="dirname"></param>
        /// <param name="filename"></param>
        /// <param name="fileByte"></param>
        public void WriteFile(string dirname, string filename, byte[] fileByte)
        {
            using (IdentityScope iss = new IdentityScope(username, hostIp, password))
            {
                string filepath = GetFileName(dirname, filename);

                var path = Path.GetDirectoryName(filepath);

                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                FileStream fs_stream = new FileStream(filepath, FileMode.CreateNew);

                BinaryWriter writefile = new BinaryWriter(fs_stream);

                writefile.Write(fileByte);

                writefile.Close();

                //using (StreamWriter sw = new StreamWriter(filepath))
                //{
                //    Stream stream = new MemoryStream(imageByte);
                //    sw.Write(fileByte);
                //}
            }
        }