|
You can speed things up by compressing, sending one by one matters not a jot, the number of bytes is the same. Add a method you call to confirm that the file exists, or just have the web method return a bool to say that it wrote it OK.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
Christian Graus wrote: You can speed things up by compressing, sending one by one matters not a jot, the number of bytes is the same
This is not 100% correct. Try sending >1000 (or any large number) files from one PC over a network to another PC (for example a shared network drive) and compare the speed with the same files compressed into a single one.
I'm not talking about compression here: the overhead for opening the files, creating the appropriate file handles and sending and receiving status commands (for FTP, e.g.) can decrease the throughput quite a lot. You can even notice the performance drop by simply copying many files from one harddrive (or partition) to another.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
1.1) You can use File.Exists
1.2) Create a hash for the file and send it to webservice along with the file.
Once it has been uploaded verify the hash on the webserver.
2) That depends on many things; including filesize, filecount, etc.
The best answer is to make a test and compare the results if performance is resuired.
Edit: arghhhh Greeeg posted faster than me just because I was making coffee
|
|
|
|
|
I want to make one of our applications auto updating. Previously I have used click-once to meet this requirement, but this time it's not an option.
The app consists of a VB6 exe which uses a bunch of C#.NET dll's. (It's been slowly ported from completely VB6, but replacing the remaining bits with C# is currently not an option).
It also includes a windows service, entirely in C#.
Both parts of the app need to auto update. Not necessarily together.
Clickonce is obviously not an option because of the VB6 and service parts of the app.
We use the enterprise library for a lot of other stuff so I started to look at the enterprise library updater application block, but it looks like it's been dropped from the newer versions.
It's only got to work on the internal network, not over the web. (So file based copies rather than FTP or IIS server downloads is probably preferable)
Are there any recommended ways of doing this?
Anything built into .Net that does it?
Any good 3rd party frameworks out there the help, that people would recommend looking at?
Or is the best thing to do just write my own?
(I'm not asking how to do it, I can manage that. I'm just asking for advice on the best route to take. What have other people done?)
Cheers
Simon
|
|
|
|
|
if i Got U Right
u Need to have a backgroundworker that Will "Pull"
information from where ever u Want to and then distribute that information To Where Ever u Want to
Have Fun
Never forget it
|
|
|
|
|
Thanks, but I've not got a problem with how to do it. If I decide to code my own, it looks pretty straight forward .
What I want to know is if anyone else has done smiler and can share their recommendations. There are frameworks and tools around (Like BITS, and the enterprise library) and I wondered if it's worth looking at them, has anyone used one and can recommend it, or if it's better just to code my own?
Thanks again.
Simon
|
|
|
|
|
|
Thanks Led Mike.
I've looked into BITS and I think its a bit of overkill for my purposes. Not much is said on the patterns and practises web site, they just seem to recommend some different techniques for writing it yourself. (They seem to have deprecated the updater application block which I find a bit odd, as there doesn't seem to be a replacement, I'm sure it would have come in handy now, never mind, they must have their reasons.)
All in all, I think I'm just going to write my own.
Cheers
Simon
|
|
|
|
|
Simon Stevens wrote: they just seem to recommend some different techniques for writing it yourself.
You do realize that is the original meaning of Patterns right? And Best Practices? That you implement them when needed, not that there is a library that you use when you need them. That would be a Library not a Pattern or Practice.
Updating an installation can be quite complex, that may be why they deprecated the library, because it was insufficient to generalized use. It might not even be possible to address all the potential aspects of updating an installation with a generalized library. Generalizations almost always add complexity to the subject and in this case it is already quite complex. How do you generalize database schema modifications which may require migration of existing data into the new schema? That's just one small example. On the other hand if ones project needs are fairly simple why would one want to use a large complex library that is capable of supporting the more complex aspects of updating an installation. I mean you are already saying that BITS is overkill, right?
Also I have no idea why your post got voted down. There is nothing bad enough about it to warrant that. Some people seem to enjoy abusing the whole voting thing.
led mike
|
|
|
|
|
Hey!
I am using a listview in virtual mode and it works fine until I want to manipulate the columns in the listview. I am not sure how to do this "synchronized" with the RetrieveVirtualItem event. Right now my application crashes if I happen to add or remove a column exactly when the listview is updating itself.
Does anyone know how to do this?
|
|
|
|
|
I am writing a C# program to ruturn the permissions of a reg key passed in the program. I have the main registry part working except when the registry path has a space.
RegistryKey
regKey = Registry.LocalMachine
regkey = regKey.OpenSubKey("Software");
regkey = regKey.OpenSubKey("Adobe");
regKey = regKey.OpenSubKey("Adobe Reader");
RegistrySecurity = regKey.GetAccessControl();
the main question is how do I handle spaces so I can read any key I am looking for?
Thanks
Rob
|
|
|
|
|
I just tried this code with "Adobe Gamma" (I don't have the reader installed) and it worked fine for me.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanks
I did not have the right key name
|
|
|
|
|
I am getting a warning message while sending mails,meeting rquests programatically. How to suppress these warnings?
can you plz help me?
|
|
|
|
|
|
I've killing myself for about a week now on this one thing. Any help would be appreciated. I'm trying to use WebClient.DownloadFileAsync so my GUI stays responsive while a file downloads. Everything works right as far as I can tell. For the split second before the crash, my GUI is still responsive. Here's how it works and where the problem comes in.
I call getfileasync to download "file.ext" from "http://whatever.com". It starts download and when AsyncCompletedEventHandler is triggered, my handler is called that loads the file that was downloaded and does stuff with it. The problem comes in when AsyncCompletedEventHandler is called. It seems like it's calling BEFORE the file is actually downloaded. When I step through in debug bug mode, I have no problems, because the file has time to fully download before I call on it again. In a straight run, I can actually watch as the error is thrown before I see the file show up in Explorer.
Here's some stripped, relevant code.
string fileName;
public void checkUpdates()
{
foreach (Uri uri in uriList)
{
fileName = uri.AbsolutePath.Remove(0, 1);
if (!File.Exists(fileName))
{
doUpdates(true, uri);
wasUpdated = true;
continue;
}
}
}
public void doUpdates(bool checkUpdates, Uri uri)
{
WebClient client = new WebClient();
client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_updateFinished);
if (checkUpdates)
client.DownloadFileAsync(uri, fileName);
}
private void client_updateFinished(object sender, AsyncCompletedEventArgs e)
{
if (File.Exists(fileName))
{
xmlDoc.Load(fileName);
}
}
I noticed that I don't have this problem when I download one file at a time. Or, if I switch the download order so the bigger of the 2 files downloads first, I don't get an error, but the second file isn't processed. After the files download, they're opened by the program and read through(xml) and every node is put into a combo box. The second file doesn't make it to that process function.
The error it throws is:
System.IO.IOException: The process cannot access the file 'file.xml' because it is being used by another process.
I assume because i'm still saving the file as I try and load it again. If I call Thread.Sleep(xxx) or Application.DoEvents it works right, but then i'm blocking again and I may as well go with synchronous sockets.
|
|
|
|
|
The first thing that pops to my mind, is run the downloader in a seperate thread/BackgroundWorker .
|
|
|
|
|
I remember I did this a while ago and never had any problems. I've just gone and checked and it turns out I used a delegate and BeginEnvoke() , although I've never tried to access the file imediatly after I got the callback. Maybe you could add a Thread.Sleep(1000); to make sure everything is finished - although it's not ideal.
Perhaps if you use a delegate like I did you won't have a problem, since this calls DownloadFile rather than the built in DownloadFileAsync , it's got to be worth a try at least.
private delegate void DownloadFile(string Address, string Path);
.
private void download(string Address, string Path)
{
System.Net.WebClient client = new WebClient();
client.DownloadFile(Address, Path);
}
.
private void internetDownload()
{
string address = ReadString();
string path = ReadString();
DownloadFile dload = new DownloadFile(download);
dload.BeginInvoke(address, path, new AsyncCallback(downloadCallback), dload);
}
.
private void downloadCallback(IAsyncResult result)
{
DownloadFile dload = result.AsyncState as DownloadFile;
dload.EndInvoke(result);
}
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Hello,
I've got very odd problem.
I use windows application to store files in data base (MySql) and then to extract this files from data base and save it on hdd. But when i save them back to hdd tihs files are 1Kb less from original file. When i insert pictures this 1kb obviously is not imported and the pictures is shown. But other files when try to be opened is corrupted or if they open some error message is shown.
So the code that i use to save file in DB is:
MySqlConnection con = new MySqlConnection("SERVER=localhost;" +
"DATABASE=db;" +
"UID=user;" +
"PASSWORD=root;");
MySqlDataAdapter da = new MySqlDataAdapter("Select * From test", con);
MySqlCommandBuilder MyCB = new MySqlCommandBuilder(da);
DataSet ds = new DataSet("test");
da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
FileStream fs = new FileStream(@"C:\image.rar", FileMode.OpenOrCreate, FileAccess.Read);
byte[] MyData = new byte[fs.Length];
fs.Read(MyData, 0, System.Convert.ToInt32(fs.Length));
fs.Close();
da.Fill(ds, "test");
DataRow myRow;
myRow = ds.Tables["test"].NewRow();
myRow["id"] = "12";
myRow["blobdata"] = MyData;
ds.Tables["test"].Rows.Add(myRow);
da.Update(ds, "test");
con.Close();
The code that extract files from database and save them to hdd is:
MySqlConnection con = new MySqlConnection("SERVER=localhost;" +
"DATABASE=db;" +
"UID=user;" +
"PASSWORD=root;");
MySqlDataAdapter da = new MySqlDataAdapter("Select * From test where id = 12", con);
MySqlCommandBuilder MyCB = new MySqlCommandBuilder(da);
DataSet ds = new DataSet("test");
byte[] MyData;
da.Fill(ds, "test");
DataRow myRow;
myRow = ds.Tables["test"].Rows[0];
MyData = (byte[])myRow["blobdata"];
int ArraySize;
ArraySize = MyData.GetUpperBound(0);
FileStream fs = new FileStream(@"C:\Data\image.rar", FileMode.OpenOrCreate, FileAccess.Write);
fs.Write(MyData, 0, ArraySize);
fs.Close();
Thanks!
King Regards!
countNazgul
modified on Thursday, July 3, 2008 10:42 AM
|
|
|
|
|
countnazgul wrote: byte[] MyData = new byte[0];
What the purpose of that?
countnazgul wrote: int ArraySize = new int();
Whats the purpose of that?
countnazgul wrote: System.Convert.ToInt32(fs.Length-1)
Whats the purpose of that?
Now, remove all that useless crap from your code, so we can at least read and understand it...
|
|
|
|
|
Ok. I remove the piece of code
King Regards!
countNazgul
|
|
|
|
|
Do U Check To See if The Data (file in your case)
was received Successfully and Fully??
there are lots of events and Methods in (MySql/ODBC/OLEDB/SQLserverDataAdapter)
Like the FillError Event
Have Fun
Never forget it
|
|
|
|
|
Yes file was OK.
But i find another solution that extract my files without a problem.
Here is and the code:
MySqlConnection Conn = new MySqlConnection("SERVER=localhost;" +
"DATABASE=db;" +
"UID=user;" +
"PASSWORD=root;");
MySqlCommand Cmd = new MySqlCommand("Select * From test where id = 19", Conn);
Cmd.CommandType = CommandType.Text;
Conn.Open();
MySqlDataReader Reader = Cmd.ExecuteReader(CommandBehavior.CloseConnection);
FileStream FStream = null;
BinaryWriter BWriter = null;
byte[] Binary = null;
const int ChunkSize = 100;
int SizeToWrite = 0;
MemoryStream MStream = null;
while (Reader.Read())
{
FStream = new FileStream(@"c:\Data\Nomenclature123.xls", FileMode.OpenOrCreate, FileAccess.Write);
BWriter = new BinaryWriter(FStream);
Binary = (Reader["blobdata"]) as byte[];
SizeToWrite = ChunkSize;
MStream = new MemoryStream(Binary);
for (int i = 0; i < Binary.GetUpperBound(0) - 1; i = i + ChunkSize)
{
if (i + ChunkSize >= Binary.Length) SizeToWrite = Binary.Length - i;
byte[] Chunk = new byte[SizeToWrite];
MStream.Read(Chunk, 0, SizeToWrite);
BWriter.Write(Chunk);
BWriter.Flush();
}
BWriter.Close();
FStream.Close();
}
FStream.Dispose();
Thank You gays for responses!
King Regards!
countNazgul
|
|
|
|
|
countnazgul wrote: Thank You gays for responses!
I'm straight, thank you.
|
|
|
|
|
I've been at this for a week now and i've only managed to connect to an open sharepoint site (public), but when it comes down to connecting to a password-protected site it becomes a pain and I can neither find nor get any methods to work without exceptions. Any help?
Thanks mates!
-Kevin
Sharp Business Systems
|
|
|
|