|
Hi friend i am creating WindowDesktop application that will upload a large size of file to the server.
now when i upload file of small size its uploaded with no problem but when i upload large size of 62Mb or so it throw exception. can any body tell me that how can i upload large file and can i also pause uploading and resume Uploading feature
<pre
filestream="" stream="new" filestream("c:\\xyz.zip",="" filemode.open);
="" byte[]="" buffer="new" byte[stream.length];
="" int="" i="0;
" while="" ((i="stream.Read(buffer,0," buffer.length))>0)
="" {
="" ftpwebrequest="" request="(FtpWebRequest)FtpWebRequest.Create("ftp://ftp.abc.com/"" +="" path.getfilename("c:\\xyz.zip"));
="" try
="" {
="" request.method="WebRequestMethods.Ftp.UploadFile;
" request.credentials="new" networkcredential("demo123",="" "demo123");
="" request.usepassive="true;
" request.usebinary="true;
" request.keepalive="false;
"
="" request.timeout="int.MaxValue;
" reqstream="request.GetRequestStream();
" reqstream.write(buffer,="" 0,="" buffer.length);
="" reqstream.beginwrite(buffer,="" buffer.length,="" callback,="" "aa");
="" reqstream.close();
="" }
="" catch="" (exception="" ex)
="" stream.close();="">
i use both Write and BeginWrite method
WANTED wasim khan(Killed 50 Innocent Buggs, Distroyed 200 Exception, make 5 Project Hostage) any Compnay Hire him will pay 30,000. Best place where u can get him is Sorcim Technologies Murre Road RWP
|
|
|
|
|
We cannot know unless you tell us what Expetion you are getting
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Hi Vuyiswa Maseko
Error is "Unable to write data to the transport connection: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full."
WANTED wasim khan(Killed 50 Innocent Buggs, Distroyed 200 Exception, make 5 Project Hostage) any Compnay Hire him will pay 30,000. Best place where u can get him is Sorcim Technologies Murre Road RWP
|
|
|
|
|
musefan is Right increase the Buffer and see what happends
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
I'm actually suggesting to reduce the buffer size.. but I assume that is what you meant anyway
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Its one of those Days
today its the Final day of my Project
Am tired
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
I see
Just out of interested what is your project? is it a course project?
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
|
Interesting
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
I have not really read your code but my first guess would be your buffer array size is causing the issue. The buffer should not contain all the data else you may as well use the stream itself.
Try a buffer size of 1024 - that's a common size that is used.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
yes i set the buffer size to 1024
it working but in process it threw exception couple of time "The underlying connection was closed: An unexpected error occurred on a receive."
WANTED wasim khan(Killed 50 Innocent Buggs, Distroyed 200 Exception, make 5 Project Hostage) any Compnay Hire him will pay 30,000. Best place where u can get him is Sorcim Technologies Murre Road RWP
|
|
|
|
|
Try creating the response stream (and closing it) outside of the while loop then just write the buffer contents in each loop.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Two things.
i = stream.Read(buffer,0, buffer.Length)
That's fine, but later on
reqStream.Write(buffer, 0, buffer.Length);
You try to send the whole buffer, but if you only read 215 bytes in to the buffer in the first place then you would be sending garbage.
You should use the variable you set before to make sure you only send what you read in.
reqStream.Write(buffer, 0, i);
It would probably be fine since the whole file would be put in the buffer, but just to be safe.
As for your other problem, if you use BeginWrite you need to wait until the callback before closing the stream, at the moment you could be closing the stream while you're still trying to send data down it.
If you where to use the regular Write method, you would probably want to check how many bytes where actually written and make sure you send all of your data.
My current favourite word is: Delicious!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Hi
I have used multiple ways to restore mysql schema through c# but it doesnot seems to work as the database doesnot restores properly,
please tell me what to do, my code for restore is as under
string filename = backupName;
StreamWriter file = new StreamWriter(filename);
file.WriteLine("@ECHO off");
file.WriteLine("cls");
file.WriteLine("set DBchoice=%1%");
file.WriteLine("set User=%2%");
file.WriteLine("set Password=%3%");
file.WriteLine("set pathchoice=%4%");
file.WriteLine("");
file.WriteLine("@REM Remove double quotes from the path");
file.WriteLine("@REM SET pathchoice=%pathchoice:\"=%");
file.WriteLine("@REM SET pathchoice=%pathchoice:\"=%");
file.WriteLine("");
file.WriteLine("mysql -u " + Id + " --password=" + pwd + " " + dbName + "<" + path);
file.Close();
the other one is
StreamReader file = new StreamReader(path);
ProcessStartInfo proc = new ProcessStartInfo();
string cmd = string.Format(@"-u{0} -p{1} -h{2} {3} {4} {5}", Id, pwd, serverHost, dbName + "<", path);
proc.FileName = "mysql";
proc.RedirectStandardInput = true;
proc.RedirectStandardOutput = false;
proc.Arguments = cmd;
proc.UseShellExecute = false;
Process p = Process.Start(proc);
string res;
res = file.ReadToEnd();
p.StandardInput.Write(res);
p.WaitForExit();
file.Close();
return "Data restored successfully";
please give me any suggestions
regards,
Mariam
|
|
|
|
|
StreamReader file = new StreamReader(fromFile);
string res;
res = file.ReadToEnd();
file.Close();
ProcessStartInfo proc = new ProcessStartInfo();
proc.FileName = "mysql.exe";
proc.CreateNoWindow = true;
proc.RedirectStandardInput = true;
proc.Arguments = string.Format(" -u{0} -p{1} -h{2} -D{3}", userName, password, serverName, databaseName);
proc.UseShellExecute = false;
p.StandardInput.Write(res);
p.StandardInput.WriteLine("quit");
|
|
|
|
|
I've try this code and it's work fine!
StreamReader file = new StreamReader(restoreFile);
ProcessStartInfo proc = new ProcessStartInfo();
string cmdArgs = string.Format(@"-u{0} -p{1} -h{2} {3}", UserID, Password, Location, DatabaseName);
proc.FileName = "C:\\Program Files\\MySQL\\MySQL Server 5.1\\bin\\mysql.exe";
proc.RedirectStandardInput = true;
proc.RedirectStandardOutput = false;
proc.Arguments = cmdArgs;
proc.UseShellExecute = false;
Process p = Process.Start(proc);
string res = file.ReadToEnd();
file.Close();
p.StandardInput.WriteLine(res);
p.Close();
"&lt;" or "<" can causes error because ProcessStartInfo doesn't recognize it!
Good Luck!
|
|
|
|
|
I have been looking around because I have big dumps (200MB) and .NET kept going out of memory.
The solution is:
ProcessStartInfo proc = new ProcessStartInfo();
string cmdArgs = string.Format(@"-u{0} -p{1} -h{2} {3}", UserID, Password, Location, DatabaseName);
proc.FileName = "C:\\Program Files\\MySQL\\MySQL Server 5.1\\bin\\mysql.exe";
proc.RedirectStandardInput = true;
proc.RedirectStandardOutput = false;
proc.Arguments = cmdArgs;
proc.UseShellExecute = false;
Process p = Process.Start(proc);
p.StandardInput.WriteLine("source " + restoreFile);
p.Close();
|
|
|
|
|
I need to develope simple sql query designer. basicaly i have problem on represent the joins. please help me to do this task.
Dushan Perera
|
|
|
|
|
Dushan123 wrote: please help me to do this task.
Any specific help you want, or should we engage our mindreading skills?
|
|
|
|
|
J4amieC wrote: or should we engage our mindreading skills?
No, save that for the forums dedicated to mindreaders
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Most of the time, this is that forum
|
|
|
|
|
J4amieC wrote: Most of the time, this is that forum
you did not have to write that, I already knew you were going to say it
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
....hmmmm, that's an interesting thought...
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
|
I need to visualize the sql joins like sql query analyzer
Dushan Perera
|
|
|
|