Click here to Skip to main content
15,922,650 members
Home / Discussions / C#
   

C#

 
GeneralRe: Type cast a enum to different enum type in the entire List; C# Pin
ptr_Electron26-Mar-13 5:40
ptr_Electron26-Mar-13 5:40 
AnswerRe: Type cast a enum to different enum type in the entire List; C# Pin
OriginalGriff26-Mar-13 6:38
mveOriginalGriff26-Mar-13 6:38 
AnswerRe: Type cast a enum to different enum type in the entire List; C# Pin
Bernhard Hiller26-Mar-13 22:29
Bernhard Hiller26-Mar-13 22:29 
QuestionHow to append connectionString from one config file to other config file Pin
NarVish26-Mar-13 1:32
NarVish26-Mar-13 1:32 
QuestionOverflow, carry, etc i C# Pin
hanzibal226-Mar-13 0:00
hanzibal226-Mar-13 0:00 
AnswerRe: Overflow, carry, etc i C# Pin
Richard MacCutchan26-Mar-13 0:08
mveRichard MacCutchan26-Mar-13 0:08 
GeneralRe: Overflow, carry, etc i C# Pin
Jonathan Nethercott26-Mar-13 0:40
professionalJonathan Nethercott26-Mar-13 0:40 
GeneralRe: Overflow, carry, etc i C# Pin
Richard MacCutchan26-Mar-13 1:03
mveRichard MacCutchan26-Mar-13 1:03 
GeneralRe: Overflow, carry, etc i C# Pin
hanzibal226-Mar-13 2:01
hanzibal226-Mar-13 2:01 
GeneralRe: Overflow, carry, etc i C# Pin
Richard MacCutchan26-Mar-13 2:10
mveRichard MacCutchan26-Mar-13 2:10 
AnswerRe: Overflow, carry, etc i C# Pin
parths26-Mar-13 21:20
parths26-Mar-13 21:20 
GeneralRe: Overflow, carry, etc i C# Pin
hanzibal226-Mar-13 22:56
hanzibal226-Mar-13 22:56 
GeneralRe: Overflow, carry, etc i C# Pin
harold aptroot26-Mar-13 23:08
harold aptroot26-Mar-13 23:08 
QuestionFile.Move/create just won't work! Pin
Goaty6510925-Mar-13 11:28
Goaty6510925-Mar-13 11:28 
AnswerRe: File.Move/create just won't work! Pin
DaveyM6925-Mar-13 11:58
professionalDaveyM6925-Mar-13 11:58 
AnswerRe: File.Move/create just won't work! Pin
Abhinav S25-Mar-13 16:47
Abhinav S25-Mar-13 16:47 
AnswerRe: File.Move/create just won't work! Pin
Richard MacCutchan26-Mar-13 0:02
mveRichard MacCutchan26-Mar-13 0:02 
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");
}
}

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.