Click here to Skip to main content
15,884,855 members
Home / Discussions / C#
   

C#

 
GeneralRe: File.Move/create just won't work! Pin
Goaty6510926-Mar-13 3:16
Goaty6510926-Mar-13 3:16 
GeneralRe: File.Move/create just won't work! Pin
Richard MacCutchan26-Mar-13 6:37
mveRichard MacCutchan26-Mar-13 6:37 
GeneralRe: File.Move/create just won't work! Pin
Goaty6510926-Mar-13 8:51
Goaty6510926-Mar-13 8:51 
GeneralRe: File.Move/create just won't work! Pin
Richard MacCutchan26-Mar-13 9:14
mveRichard MacCutchan26-Mar-13 9:14 
GeneralRe: File.Move/create just won't work! Pin
Goaty6510926-Mar-13 18:43
Goaty6510926-Mar-13 18:43 
GeneralRe: File.Move/create just won't work! Pin
Goaty6510926-Mar-13 19:42
Goaty6510926-Mar-13 19:42 
GeneralRe: File.Move/create just won't work! Pin
Richard MacCutchan26-Mar-13 22:42
mveRichard MacCutchan26-Mar-13 22:42 
QuestionI want to add progress bar for ftp download for the following code Pin
Friendsaa25-Mar-13 10:25
Friendsaa25-Mar-13 10:25 
string[] files = GetFileList();
foreach (string file in files)
{
Download(file);
}
public string[] GetFileList()
{
string[] downloadFiles;
StringBuilder result = new StringBuilder();
WebResponse response = null;
StreamReader reader = null;
try
{
FtpWebRequest reqFTP;
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP + "/"));
reqFTP.UseBinary = true;
reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
reqFTP.Method = WebRequestMethods.Ftp.ListDirectory;
reqFTP.Proxy = null;
reqFTP.KeepAlive = false;
reqFTP.UsePassive = false;
response = reqFTP.GetResponse();
reader = new StreamReader(response.GetResponseStream());
string line = reader.ReadLine();
while (line != null)
{
result.Append(line);
result.Append("\n");
line = reader.ReadLine();
}
// to remove the trailing '\n'
result.Remove(result.ToString().LastIndexOf('\n'), 1);
return result.ToString().Split('\n');
}
catch (Exception ex)
{
if (reader != null)
{
reader.Close();
}
if (response != null)
{
response.Close();
}
downloadFiles = null;
return downloadFiles;
}
}
private void Download(string file)
{
try
{
string uri = "ftp://" + ftpServerIP + "/" + remoteDir + "/" + file;
Uri serverUri = new Uri(uri);
if (serverUri.Scheme != Uri.UriSchemeFtp)
{
return;
}
FtpWebRequest reqFTP;
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP + "/" + remoteDir + "/" + file));
reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
reqFTP.KeepAlive = false;
reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;
reqFTP.UseBinary = true;
reqFTP.Proxy = null;
reqFTP.UsePassive = false;
FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
Stream responseStream = response.GetResponseStream();
FileStream writeStream = new FileStream(localDestnDir + "\" + file, FileMode.Create);
int Length = 2048;
Byte[] buffer = new Byte[Length];
int bytesRead = responseStream.Read(buffer, 0, Length);
while (bytesRead > 0)
{
writeStream.Write(buffer, 0, bytesRead);
bytesRead = responseStream.Read(buffer, 0, Length);
}
writeStream.Close();
response.Close();
}
catch (WebException wEx)
{
MessageBox.Show(wEx.Message, "Download Error");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Download Error");
}
}
AnswerRe: I want to add progress bar for ftp download for the following code Pin
Abhinav S25-Mar-13 16:50
Abhinav S25-Mar-13 16:50 
AnswerRe: I want to add progress bar for ftp download for the following code Pin
GuyThiebaut25-Mar-13 22:39
professionalGuyThiebaut25-Mar-13 22:39 
QuestionWhat is Jabber client ? Pin
Tridip Bhattacharjee25-Mar-13 9:49
professionalTridip Bhattacharjee25-Mar-13 9:49 
AnswerRe: What is Jabber client ? Pin
Peter_in_278025-Mar-13 10:54
professionalPeter_in_278025-Mar-13 10:54 
AnswerRe: What is Jabber client ? Pin
Dave Kreskowiak25-Mar-13 11:01
mveDave Kreskowiak25-Mar-13 11:01 
GeneralRe: What is Jabber client ? Pin
Tridip Bhattacharjee25-Mar-13 21:27
professionalTridip Bhattacharjee25-Mar-13 21:27 
GeneralRe: What is Jabber client ? Pin
Dave Kreskowiak26-Mar-13 1:44
mveDave Kreskowiak26-Mar-13 1:44 
AnswerRe: What is Jabber client ? Pin
Pete O'Hanlon25-Mar-13 22:40
mvePete O'Hanlon25-Mar-13 22:40 
AnswerRe: What is Jabber client ? Pin
Richard MacCutchan25-Mar-13 23:50
mveRichard MacCutchan25-Mar-13 23:50 
QuestionSerialization and object versioning Pin
Abyss25-Mar-13 9:39
Abyss25-Mar-13 9:39 
AnswerRe: Serialization and object versioning Pin
Eddy Vluggen25-Mar-13 23:31
professionalEddy Vluggen25-Mar-13 23:31 
QuestionHow to do code optimization in c# apps Pin
Tridip Bhattacharjee25-Mar-13 9:30
professionalTridip Bhattacharjee25-Mar-13 9:30 
GeneralRe: How to do code optimization in c# apps Pin
harold aptroot25-Mar-13 10:41
harold aptroot25-Mar-13 10:41 
AnswerRe: How to do code optimization in c# apps Pin
jschell26-Mar-13 8:39
jschell26-Mar-13 8:39 
QuestionFew question about static class c# Pin
Tridip Bhattacharjee25-Mar-13 5:01
professionalTridip Bhattacharjee25-Mar-13 5:01 
AnswerRe: Few question about static class c# Pin
PIEBALDconsult25-Mar-13 5:14
mvePIEBALDconsult25-Mar-13 5:14 
AnswerRe: Few question about static class c# Pin
Paulo Zemek25-Mar-13 5:39
mvaPaulo Zemek25-Mar-13 5:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.