|
Check files permissions/ownership on disk.
bug_aonz wrote: ***Sorry, I don't know how to post code with paragraph. =)
Enclose your code between <pre> and </pre> tags.
-----
If atheism is a religion, then not collecting stamps is a hobby. -- Unknown
God is the only being who, to rule, does not need to exist. -- Charles Baudelaire
|
|
|
|
|
Le Centriste wrote: Check files permissions/ownership on disk.
Yep,All of them are allowed to download.When i normally download them (without asynchronous) ,It works properly. i use the code below with multi-threading
HttpWebRequest req = (HttpWebRequest) WebRequest.Create(TargetFilePath);
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
Stream stm = resp.GetResponseStream();
int ReadCount;
byte[] buffer = new byte[65535];
FileStream f = File.Open(SaveDirectory + "/" + filename
, FileMode.Append
, FileAccess.Write, FileShare.None);
if (stm.CanRead)
{
while ((int)(ReadCount = stm.Read(buffer, 0, buffer.Length)) > 0)
{
f.Write(buffer, 0, ReadCount);
}
}
f.Flush();
f.Close();
the code above can download all my collection of files.
Is it about asynchronous method?
Have i missed something to implement AsyncCallback?
|
|
|
|
|
Maybe you are blowing off the maximum number of concurrent downloads. All threads are downloading concurrently.
This is good, except that your DownloadItem calls does not have a safe guard. Suppose someone passes an array list of thousands of files to download.
I would make an app.config file that would contain a value for the maximum of concurrent downloads, and queue the rest of the items to download.
If you allow me to point out, don't use the System.Threading.Thread class to perform a job which terminates the thread when done, like downloading a file. Consider using the BackgroundWorker[^] class or asynchronous programming using delegates[^] (BackgroundWorker would be my choice here).
The main advantage of the above is that the runtime uses a thread from a thread pool it secretly manages for you, so you don't have the overhead of starting/managing your threads.
-----
If atheism is a religion, then not collecting stamps is a hobby. -- Unknown
God is the only being who, to rule, does not need to exist. -- Charles Baudelaire
|
|
|
|
|
Thank to share your good ideas. i wil try it.
|
|
|
|
|
How to search for a file in a folder using asp.net.
|
|
|
|
|
One way is
string[] files = Directory.GetFiles("c:\\dev", "*.cs");
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi everyone I am trying to subtract cells in excel from a C# application.I have a for loop that fills the cells in excel. Thanks
|
|
|
|
|
To insert a formula into a cell just write the formula you want into that cell instead of assigning the cell a hardcoded value, exactly like you would using MS Excel
|
|
|
|
|
No you cant because I have a for loop and if you put that into excel its only going to sum 2 cells not the for loop but its ok I got it right.Thanks for youre answer.
|
|
|
|
|
Hi All
I am facing a strange issue and i am working on this issue for last one week,but i am not able to find it.I have a window service which reads the MSMQ .This windows service will do only this function.Now, when some thing is written to MSMQ, window service will read the msmq.Now there is nothing in queue ,then also it will loop and if some thing comes inside the msmq then again it will read ...this works fine if i am doing in regular intervals.
Now if am not doing any operations for two or three hours ,then status of windows service will be started but it will not reading the msmq,and it is not throwing any error..also...this is the strange thing i am facing..why it is behaving like this.Can any one help me in this idea.I am pasting the start section of of mywindows service here .can any one tell me what is wrong in this code.Thanks in advance
this code i am calling inside a thread..
try
{
MessageQueue mq = null;
System.Messaging.Message msg = null;
while(true)
{
//MessageQueue mq = null;
//System.Messaging.Message msg = null;
try
{
if(mq == null)
{
mq = new System.Messaging.MessageQueue (XMLReprocessMSMQPath);
}
RemoteLoggingManager.LogMessage(LoggingMessageTypes.Error, APPLICATIONNAME,"Read Queue", LoggingMessageTargets.Both);
msg = mq.Receive(new TimeSpan(0,0,0,10,0));
RemoteLoggingManager.LogMessage(LoggingMessageTypes.Error, APPLICATIONNAME,"Data Rec", LoggingMessageTargets.Both);
msg.Formatter = new ActiveXMessageFormatter();
XMLReprocessMSMQFileName=ReceiveMessage(msg.Body.ToString());
SendXMLToWebervice(XMLReprocessMSMQFileName);
}
catch (System.Messaging.MessageQueueException ex)
{
if(ex.ErrorCode != -2147467259) // Ignore timeout error
{
RemoteLoggingManager.LogMessage(LoggingMessageTypes.Error, APPLICATIONNAME,ex.ToString(), LoggingMessageTargets.Both);
mq.Close();
mq.Dispose();
mq = null;
MessageQueue.ClearConnectionCache();
Thread.Sleep(10000);
}
else
{
mq = null;
}
}
catch (Exception ex)
{
RemoteLoggingManager.LogMessage(LoggingMessageTypes.Error, APPLICATIONNAME,ex.ToString(), LoggingMessageTargets.Both);
mq.Close();
mq.Dispose();
mq = null;
MessageQueue.ClearConnectionCache();
}
}
}
catch(Exception ex)
{
RemoteLoggingManager.LogMessage(LoggingMessageTypes.Information , APPLICATIONNAME,
"Reprocess MSMQ Catch block :" + DateTime.Now.ToLongTimeString(), LoggingMessageTargets.Both);
}
finally
{
RemoteLoggingManager.LogMessage(LoggingMessageTypes.Information , APPLICATIONNAME,"Finally block executed " +
DateTime.Now.ToLongTimeString(), LoggingMessageTargets.Both);
}
Regards
DilipRam
|
|
|
|
|
Hi guys.
I have, after alot of hard work, finally got this to work - well.... almost
I have a remoting server using TCPChannel. And i got some clients connecting to this server. When i from the beginning connects 3 client, all works fine, when someone connects, the server sends events to each client that they should update their list of clients. But when one of them Disconnects with this code:
if (SignedIn)<br />
{<br />
server.SignOut(MyUniqueID);
ChannelServices.UnregisterChannel(Channel);<br />
}
And then siqns in again, he's not getting the event when someone connects or disconnects, but the other clients does, even when the failing client connects/disconnects. BUT if i close this one client that fails, and open it up again, it all work just fine again, very strange.
I got a very simple and clean example code if anyone wants to help me
BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider();<br />
serverProv.TypeFilterLevel = TypeFilterLevel.Full;<br />
<br />
IDictionary props = new Hashtable();<br />
props["name"] = "ServerChannel";<br />
props["port"] = 666;<br />
<br />
<br />
TcpChannel Channel = new TcpChannel(props, null, serverProv);<br />
ChannelServices.RegisterChannel(Channel, false);<br />
RemotingConfiguration.RegisterWellKnownServiceType(typeof(Server), "Server", WellKnownObjectMode.Singleton);<br />
<br />
Console.WriteLine("Server is running...");
inaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider();<br />
serverProv.TypeFilterLevel = TypeFilterLevel.Full;<br />
IDictionary props = new Hashtable();<br />
props["port"] = 0;<br />
<br />
CallbackSink.OnHostToClient += new ClientEvent(OnHostToClient);<br />
<br />
Channel = new TcpChannel(props, null, serverProv);<br />
ChannelServices.RegisterChannel(Channel, false);<br />
server = (Server)Activator.GetObject(typeof(Server), "tcp://127.0.0.1:666/Server");
|
|
|
|
|
|
|
Hello,
can anyone illustrate a step by step procedure for using resource manager or some equvalent in C#.
I am not able to embed the main assembly resource file, .resources, in
the executable assembly.So please guide me in creating and embedding resource files as well.
Keshav Kamat
India
|
|
|
|
|
Look around on this site, there are some articles on embedding resources into assemblies.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Some of the functionalities can't write in .net easily, where as possible in C, C++, VC++. So how to use those libraries in .NET (C#).
|
|
|
|
|
|
Hi,
I have created a DLL in dotnet and it accepts one parameter i.e string.
When i call the method of the dll it throws me following error:
Error Type:
Microsoft VBScript runtime (0x800A01C2)
Wrong number of arguments or invalid property assignment: 'display'
/project/usedll.asp, line 46
Please suggest.
Pavas
|
|
|
|
|
How are you calling the method in that dll ?
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
'Below is the code in ASP file. I am sending a int value
Dim Obj
int i
i=2
Set Obj = Server.CreateObject("ClassLibrary1.Class1")
response.write Obj.methodname (i)
Pavas
|
|
|
|
|
But you sending the int instead of string ...
mpavas wrote: Obj.methodname (i)
Check the argument that the method is expecting
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
I tried sending both and Int and String. Both of them resulted in an error
The method detail in C#
public int PostCreate(int key)
{
return key;
}
Pavas
|
|
|
|
|
Let me reframe. This dll is created in .NET and I am using it in ASP. The dll works fine with out parameters.
Pavas
|
|
|
|
|
Hello,
Which are the faster functions in order to read/write a file?
I must write string in a file in a cycle and must be fastest possible!
Thanks a lot.
Alex
|
|
|
|
|
1) Have you meassured a performance problem or are you simply expecting it? Unless you do something strange I doubt you will notice any performance differences between the various ways of writing to files.
2) If you have performance problems are you sure it is not in the disk IO system instead of your code? If it is, get faster disks or more memory for diskcache, or start collecting changes in memory and write them in batches (possible on a worker thread, but then you must take care of locking etc).
Besides this it is not easy to help you when you do not provide more information on what you are trying to write and for what purpose.
|
|
|
|
|