/// <summary>
///
/// </summary>
/// <param name="Fid"></param>
/// <param name="fname"></param>
/// <param name="FPath"></param>
/// <param name="IsDel"></param>
public void RemoteDownData(string Fid,string fname,string FPath,bool IsDel)
{
DirectoryInfo Dir = new DirectoryInfo(FPath);
if(!Dir.Exists)
Dir.Create();
else
{
if(IsDel)
{
foreach(FileInfo file in Dir.GetFiles())
{
file.Delete();
}
}
}
PbaseUpdate Pbase = new PbaseUpdate();
DataTable DtCode =Pbase.GetDatetable(null,"select FCODE,FID from DNC_PRODUCTPROGRAM_CODE where fid='"+Fid+"'");
if(DtCode.Rows.Count<=0)return;
byte[] buffer=(byte[])DtCode.Rows[0][0];
FPath = FPath + fname;
FileStream Fs = File.OpenWrite(FPath);
Fs.Write(buffer,0,buffer.Length);
Fs.Close();
DtCode.Dispose();
}
/// <summary>
///
/// </summary>
/// <param name="FPath"></param>
public bool RemoteDelDir(string FPath)
{
FileInfo RFile = new FileInfo(FPath);
if( RFile.Exists)
{
return SigleFileDel(FPath);
}
else
{
DirectoryInfo Dir = new DirectoryInfo(FPath);
if(!Dir.Exists)return false;
if(Dir.GetFiles().Length <= 0)
{
Dir.Delete();
return true;
}
else
{
foreach(FileInfo file in Dir.GetFiles())
{
string FilePath = file.FullName;
if(!SigleFileDel(FilePath))
return false;
}
Dir.Delete();
return true;
}
}
}
private bool SigleFileDel(string FilePath)
{
FileInfo file = new FileInfo(FilePath);
if(file.Exists)
{
file.Delete();
return true;
}
else
{
return false;
}
}
------------------------------------------------------------------------------------------------------------
转载于:https://www.cnblogs.com/modernsky2003/archive/2007/12/14/994988.html