Commit b26ec13b by 肖小磊

STLD上传

parent 9840c473
No preview for this file type
......@@ -10,26 +10,7 @@ namespace GoMaxWakeUpSC
{
static void Main(string[] args)
{
//WakeUpHelper.Run();
string s = DateTime.Now.ToString("yy");
string[] files = Directory.GetFiles(@"c:\");//得到文件
List<string> srcfiles = new List<string>();
ZipClass.ZipNo(@"D:\ziptest","c:\\1.zip");
string zipfilename = "test.zip";
FileStream fs = File.Create(zipfilename);
using (ZipFile zip = new ZipFile(fs))
{
foreach (string file in files)//循环文件
{
zip.Add(file);
}
zip.Close();
}
WakeUpHelper.Run();
}
}
}
......@@ -15,3 +15,12 @@ D:\Project\GoMax\New\Fi\GoMaxWakeUpSC\bin\Debug\Newtonsoft.Json.xml
D:\Project\GoMax\New\Fi\GoMaxWakeUpSC\obj\Debug\GoMaxWakeUpSC.exe
D:\Project\GoMax\New\Fi\GoMaxWakeUpSC\obj\Debug\GoMaxWakeUpSC.pdb
D:\Project\GoMax\New\Fi\GoMaxWakeUpSC\obj\Debug\GoMaxWakeUpSC.csprojResolveAssemblyReference.cache
D:\Project\GoMaxNew\GoMaxTools\GoMaxWakeUpSC\bin\Debug\GoMaxWakeUpSC.exe.config
D:\Project\GoMaxNew\GoMaxTools\GoMaxWakeUpSC\bin\Debug\GoMaxWakeUpSC.exe
D:\Project\GoMaxNew\GoMaxTools\GoMaxWakeUpSC\bin\Debug\GoMaxWakeUpSC.pdb
D:\Project\GoMaxNew\GoMaxTools\GoMaxWakeUpSC\bin\Debug\ICSharpCode.SharpZipLib.dll
D:\Project\GoMaxNew\GoMaxTools\GoMaxWakeUpSC\bin\Debug\Newtonsoft.Json.dll
D:\Project\GoMaxNew\GoMaxTools\GoMaxWakeUpSC\bin\Debug\Newtonsoft.Json.xml
D:\Project\GoMaxNew\GoMaxTools\GoMaxWakeUpSC\obj\Debug\GoMaxWakeUpSC.csprojResolveAssemblyReference.cache
D:\Project\GoMaxNew\GoMaxTools\GoMaxWakeUpSC\obj\Debug\GoMaxWakeUpSC.exe
D:\Project\GoMaxNew\GoMaxTools\GoMaxWakeUpSC\obj\Debug\GoMaxWakeUpSC.pdb
......@@ -69,6 +69,8 @@ namespace GoMaxCopyFileService
{
string TempDir = ConfigurationManager.AppSettings["FileSharePath"];
string TargetDir = ConfigurationManager.AppSettings["KlspokePath"];
string user = ConfigurationManager.AppSettings["KlspokePathUser"];
string pwd = ConfigurationManager.AppSettings["KlspokePathPwd"];
int FileCount = Convert.ToInt32(ConfigurationManager.AppSettings["FileCount"]);
DirectoryInfo temp_di = new DirectoryInfo(TempDir);
while (true)
......@@ -93,6 +95,7 @@ namespace GoMaxCopyFileService
var files = temp_di.GetFiles();
if (files.Length == 0)
{
//LogHelper.WriteLog("没有文件,休息5秒:" + tsKlsExecuteTime, "CopyKlsFileInfo");
Thread.Sleep(1000 * 5);
continue;
}
......@@ -109,8 +112,12 @@ namespace GoMaxCopyFileService
for (int i = 0; i < length; i++)
{
FileInfo file = files[i];
File.Move(file.FullName, TargetDir + Path.GetFileName(file.FullName));
LogHelper.WriteLog(file.FullName + "移动成功", "CopyKlsFileInfo");
//File.Move(file.FullName, TargetDir + Path.GetFileName(file.FullName));
string uri = "ftp://" + TargetDir + "/" + file.Name;
FtpHelper.UpLoad(file.FullName, uri, user, pwd);
File.Delete(file.FullName);
LogHelper.WriteLog(file.FullName + "上传成功", "CopyKlsFileInfo");
}
LogHelper.WriteLog("处理完毕,开始休息一个小时", "CopyKlsFileInfo");
Thread.Sleep(1000 * 60 * 60);
......
......@@ -48,5 +48,45 @@ namespace GoMaxCopyFileService
strm.Close();
fs.Close();
}
public static void UpLoad(string fileName, string uri, string user, string pwd)
{
FileInfo fileInfo = new FileInfo(fileName);
//string uri = "ftp://" + ConfigurationManager.AppSettings["FtpPath"] + "/" + fileInfo.Name;
FtpWebRequest reqFTP;
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri));
reqFTP.Credentials = new NetworkCredential(user, pwd);
reqFTP.KeepAlive = false;
reqFTP.Method = WebRequestMethods.Ftp.UploadFile;
reqFTP.UseBinary = true;
reqFTP.ContentLength = fileInfo.Length;
int buffLength = 2048;
byte[] buff = new byte[buffLength];
int contentLen;
FileStream fs = fileInfo.OpenRead();
Stream strm = reqFTP.GetRequestStream();
contentLen = fs.Read(buff, 0, buffLength);
while (contentLen != 0)
{
strm.Write(buff, 0, contentLen);
contentLen = fs.Read(buff, 0, buffLength);
}
strm.Close();
fs.Close();
}
}
}
......@@ -74,7 +74,9 @@
<Compile Include="ZipClass.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="App.config">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
......
......@@ -25,3 +25,8 @@ D:\Project\GoMax\GoMaxSH\GoMaxTools\WindowsService2\obj\Debug\GoMaxCopyFileServi
D:\Project\GoMaxNew\GoMaxTools\WindowsService2\bin\Debug\GoMaxCopyFileService.exe.config
D:\Project\GoMaxNew\GoMaxTools\WindowsService2\obj\Debug\GoMaxCopyFileService.exe
D:\Project\GoMaxNew\GoMaxTools\WindowsService2\obj\Debug\GoMaxCopyFileService.pdb
D:\Project\GoMaxNew\GoMaxTools\WindowsService2\bin\Debug\GoMaxCopyFileService.exe
D:\Project\GoMaxNew\GoMaxTools\WindowsService2\bin\Debug\GoMaxCopyFileService.pdb
D:\Project\GoMaxNew\GoMaxTools\WindowsService2\bin\Debug\ICSharpCode.SharpZipLib.dll
D:\Project\GoMaxNew\GoMaxTools\WindowsService2\obj\Debug\GoMaxCopyFileService.ProjectInstaller.resources
D:\Project\GoMaxNew\GoMaxTools\WindowsService2\obj\Debug\GoMaxCopyFileService.csproj.GenerateResource.Cache
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment