跳到主要內容

發表文章

目前顯示的是 12月, 2016的文章

How to remove a substring via batch command

Here is a tip to remove a substring via batch command For example: If I'd like to remove file extension name  from  Install .wim to  Install We can try below command: Test.cmd SET WINPE=%1 echo %WINPE% SET WINPE=%WINPE:.wim=% echo %WINPE% Input:  Test.cmd Install.wim Output:  Install REF: http://www.dostips.com/DtTipsStringManipulation.php

[Batch][loop] Recurse find specified file and do something

Assume you need to update many  Setting.xml  in the specified directory and they locate on different sub-folders. You can copy&past one-by-one if you have a lot of time to do this. Or you can try below batch script:  SET FileName ="C:\Users\Andy\Dropbox\ Setting.xml " FOR /F  "usebackq delims==" %%i IN (`dir /b /s Setting.xml `) DO COPY /Y  %FileName% "%%i"

[C#] FTP download sample code

If you'd like DL file through  WebRequestMethods, maybe you could try below sample code Input: filePath = "ftp://100.251.237.125/update.xml" targetPath  = update.xml public bool DwonlaodFileFromFTP( string filePath, string targetPath, out string errorMessage)         {             // initialize                      FtpWebRequest request = ( FtpWebRequest ) WebRequest .Create(filePath);             request.Credentials = new NetworkCredential (_user, _password);             request.Proxy = null ;             request.Method = WebRequestMethods . Ftp .DownloadFile;             request.UsePassive = false ;                         FtpWebResponse response = ( FtpWebResponse )request.GetResponse();             Stream responseStream = response.GetResponseStream();                           using ( Stream fileWriter = File .Create(targetPath))             {                 responseStream.C

[C#] FtpWebRequest failed

[C#] FtpWebRequest fails  I try to list files using FtpWebRequest but  it fails with a WebException 'The underlying connection was closed: An unexpected error occurred on a receive.'             string ftpPath = "ftp://" + this ._ip;                          FtpWebRequest request = ( FtpWebRequest ) WebRequest .Create(ftpPath);             request.Credentials = new NetworkCredential (_user, _password);             request.Proxy = null ;             request.Method = WebRequestMethods . Ftp .ListDirectory;              FtpWebResponse response = ( FtpWebResponse )request.GetResponse();              Stream responseStream = response.GetResponseStream();     >> Exception!!! After trial and error, I found I need to set  Active Mode  for connection (default Passive property is  false)             string ftpPath = "ftp://" + this ._ip;             FtpWebRequest request = ( FtpWebRequest ) WebReques