Click here to Skip to main content
15,887,027 members
Home / Discussions / C#
   

C#

 
GeneralRe: Byte Conversion Pin
Agweet10-Dec-08 20:59
Agweet10-Dec-08 20:59 
GeneralRe: Byte Conversion Pin
N a v a n e e t h10-Dec-08 21:05
N a v a n e e t h10-Dec-08 21:05 
GeneralRe: Byte Conversion Pin
Agweet10-Dec-08 21:10
Agweet10-Dec-08 21:10 
GeneralRe: Byte Conversion Pin
Giorgi Dalakishvili10-Dec-08 21:09
mentorGiorgi Dalakishvili10-Dec-08 21:09 
GeneralRe: Byte Conversion Pin
Agweet10-Dec-08 21:13
Agweet10-Dec-08 21:13 
GeneralRe: Byte Conversion Pin
Giorgi Dalakishvili10-Dec-08 21:18
mentorGiorgi Dalakishvili10-Dec-08 21:18 
GeneralRe: Byte Conversion Pin
Agweet10-Dec-08 21:23
Agweet10-Dec-08 21:23 
QuestionUploading data using ftpwebrequest method in c# Pin
vnr10-Dec-08 20:19
vnr10-Dec-08 20:19 
hi,

in my application i need to upload the data to the serevr using ftpwebrequest method .I need to upload 2 files one is a zip file (more than 10 MB) and other is a text file to the same server. when iam uploading total zip content is not getting uploaded to the serevr and its returning error like
" The underlying connection was closed: An unexpected error occurred on a receive." So please can anybody help me where exactly the problem is.Is that the problem with the code or serevr settings.


Thanks in advance


Here is my code

private static void Upload()
{
string[] strar = new string[] { sourcepath + ".zip", sourcepath + ".txt" };
foreach (string str in strar)
{
FileInfo fileInf = new FileInfo(str);

string uri = "ftp://" + ftpServerIP + "/" + fileInf.Name;
FtpWebRequest reqFTP;

// Create FtpWebRequest object from the Uri provided
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP + "/" + fileInf.Name));




//Set the proxy to null to get around the "the requested ftp command is not supported when using http proxy" error
reqFTP.Proxy = null;

reqFTP.Timeout = 2000000000;


// Provide the WebPermission Credintials
reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);

// By default KeepAlive is true, where the control connection is not closed
// after a command is executed.
reqFTP.KeepAlive = false;

// Specify the command to be executed.
reqFTP.Method = WebRequestMethods.Ftp.UploadFile;

// Specify the data transfer type.
reqFTP.UseBinary = true;

// Notify the server about the size of the uploaded file
reqFTP.ContentLength = fileInf.Length;

// The buffer size is set to 2kb
int buffLength = 2048;
byte[] buff = new byte[buffLength];
int contentLen;

// Opens a file stream (System.IO.FileStream) to read the file to be uploaded
FileStream fs = fileInf.OpenRead();

try
{
// Stream to which the file to be upload is written
Stream strm = reqFTP.GetRequestStream();
//mydelegate delinstance = new mydelegate(Writedata);
//int result;



//Stream strm = reqFTP.BeginGetRequestStream(null, null);
//Stream strm = reqFTP.BeginGetRequestStream(delinstance,result);

// Read from the file stream 2kb at a time
contentLen = fs.Read(buff, 0, buffLength);
//progressBar1.Maximum = contentLen;
// Till Stream content ends
//progressBar1.Step=10;

while (contentLen != 0)
{
// Write Content from the file stream to the FTP Upload Stream
strm.Write(buff, 0, contentLen);
contentLen = fs.Read(buff, 0, buffLength);
//if (progressBar1.Value < progressBar1.Maximum)
// progressBar1.PerformStep();
}
//progressBar1.Value = 0;

// Close the file stream and the Request Stream
strm.Close();
fs.Close();
Console.WriteLine("Uploading completed for file " + str);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message, " Upload Error");
Console.ReadLine();
}
Console.ReadLine();
}
}
Questionvalidation Pin
kulandaivel_mca200710-Dec-08 20:12
kulandaivel_mca200710-Dec-08 20:12 
AnswerRe: validation Pin
Giorgi Dalakishvili10-Dec-08 20:14
mentorGiorgi Dalakishvili10-Dec-08 20:14 
AnswerRe: validation Pin
dan!sh 10-Dec-08 21:19
professional dan!sh 10-Dec-08 21:19 
QuestionRun ppt with C# - urgent !!!! Pin
salon10-Dec-08 19:05
salon10-Dec-08 19:05 
AnswerRe: Run ppt with C# - urgent !!!! Pin
Christian Graus10-Dec-08 19:19
protectorChristian Graus10-Dec-08 19:19 
GeneralRe: Run ppt with C# - urgent !!!! Pin
salon10-Dec-08 19:43
salon10-Dec-08 19:43 
GeneralRe: Run ppt with C# - urgent !!!! Pin
N a v a n e e t h10-Dec-08 19:52
N a v a n e e t h10-Dec-08 19:52 
GeneralRe: Run ppt with C# - urgent !!!! Pin
salon10-Dec-08 20:04
salon10-Dec-08 20:04 
GeneralRe: Run ppt with C# - urgent !!!! Pin
Giorgi Dalakishvili10-Dec-08 20:12
mentorGiorgi Dalakishvili10-Dec-08 20:12 
GeneralRe: Run ppt with C# - urgent !!!! Pin
salon10-Dec-08 22:35
salon10-Dec-08 22:35 
GeneralRe: Run ppt with C# - urgent !!!! Pin
Michael Bookatz10-Dec-08 23:41
Michael Bookatz10-Dec-08 23:41 
GeneralRe: Run ppt with C# - urgent !!!! Pin
salon11-Dec-08 0:26
salon11-Dec-08 0:26 
GeneralRe: Run ppt with C# - urgent !!!! Pin
Christian Graus11-Dec-08 8:10
protectorChristian Graus11-Dec-08 8:10 
QuestionReading Content Of Doc Files Pin
Laji5910-Dec-08 19:01
Laji5910-Dec-08 19:01 
AnswerRe: Reading Content Of Doc Files Pin
Christian Graus10-Dec-08 19:18
protectorChristian Graus10-Dec-08 19:18 
AnswerRe: Reading Content Of Doc Files Pin
hotthoughtguy10-Dec-08 19:20
hotthoughtguy10-Dec-08 19:20 
GeneralRe: Reading Content Of Doc Files Pin
Christian Graus10-Dec-08 19:27
protectorChristian Graus10-Dec-08 19:27 

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.