|
Björn T.J.M. Spruit wrote: Though, you'd get to the same point when a developer finds out, that the process it returns, is the one the developer is debugging or has built.
Why have that developer (who can't figure out his own app locked a file) go through the pain of writing another app he doesn't understand just to find out he screwed up in his original app?
Björn T.J.M. Spruit wrote: I'd prefer they'd find out for themselves in an easy way, instead of them having to bother me.
Most of the people who are asking the question don't have a clue about what they're doing, let alone have the ability to teach themselves anything.
Björn T.J.M. Spruit wrote: I'm all for self-reliance
Björn T.J.M. Spruit wrote: I'm all for self-reliance.
So am I. Too bad this business has been overrun by idiots who couldn't teach themselves how to use Notepad let alone how get to Yahoo or Google and do any kind of research whatsoever.
|
|
|
|
|
That is why I stopped asking questions on the Internet. Too many people who don't have the answer feel inclined to respond without realizing all they are doing is wasting someone else's time. Of course, I am doing that right now since I don't have the answer either but I am at least self-aware making me an A**hole and not a moron.
|
|
|
|
|
Do you know what, ive pretty much stoped answering questions on the internet for exactly the opposite reason - people get uppity when you actually question why they are trying to do something one way when there is a reason we don't generally do it that way.
|
|
|
|
|
There is a difference between questioning a novice developers approach and questioning an experienced developers question.
|
|
|
|
|
And so the elitists decide whether they feel like helping or not.
Mostly deciding whether they deem it worthy of their time and effort.
Helping isn't performing an act in furthering yourself, it's an act of furthering others.
A concept, it seems, hard to grasp for some.
And yes, I'm not a novice.
And yes, my question is valid and I'll not have that debated.
So in the interest of furthering the one that asked a valid question, I gladly refer to the original post.
Any insights, other than the ones given, are welcome.
|
|
|
|
|
Hello Readers,
I am downloading a Html File using the following method.
<pre>public void LoadInitialData()
{
HttpWebRequest request = null;
try
{
Stopwatch sw = new Stopwatch();
RaiseStateChangedEvent(10, "Creating Connection to Server");
request = (HttpWebRequest)(WebRequest.Create(this._ServerUrl));
RaiseStateChangedEvent(20, "Connected to Server");
int timeout = request.Timeout;
if (request != null)
{
try
{
sw.Start();
request.BeginGetResponse(HttpRequestCallBackMethod, request);
sw.Stop();
RaiseStateChangedEvent(40, "Waiting for Data from Server --Time Taken: " + sw.ElapsedMilliseconds);
}
catch (Exception ex)
{
if (onErrorOccured != null)
onErrorOccured(ex.Message + "\n" + ex.StackTrace);
}
}
}
catch (Exception ex)
{
if (onErrorOccured != null)
onErrorOccured(ex.Message + "\n" + ex.StackTrace);
}
}
private void HttpRequestCallBackMethod(IAsyncResult iar)
{
RaiseStateChangedEvent(70, "Data Received From Server");
HttpWebRequest myHttpWebRequest = iar.AsyncState as HttpWebRequest;
HttpWebResponse response = (HttpWebResponse)myHttpWebRequest.EndGetResponse(iar);
using (StreamReader input = new StreamReader(response.GetResponseStream()))
{
string data = input.ReadToEnd();
RaiseStateChangedEvent(80, "Processing received Data");
ProcessData(data);
RaiseStateChangedEvent(100, "Completed Loading Initial Data");
}
}
private void RaiseStateChangedEvent(int progress, string message)
{
if (onStateChanged != null)
onStateChanged.Invoke(progress, message);
}
private void ProcessData(string data)
{
Console.WriteLine("Download Completed - Do any Processing here");
}</pre>
The program is written in .Net 2.0. When I try to run the same in Windows 7, I am not successful.
In Win7, Whenever I am calling this method continously (ie, 10 times in a for loop), I am not getting the replies for all the requests (the callback is not executed all time, only 5 or 6 responses I am getting). In 2000, Xp, Vista the program runs with no problem.
I have added a stopwatch to mesure the time it takes to invoke request.BeginGetResponse method. And the initial request is blocking the while application for 3 seconds (usually it should not. By calling teh LoadInitialData method in a seperate thread I managed the application from blocking).
Can anybody give some suggestions about this problem?
Thanks in advance.
|
|
|
|
|
Hello Readers,
I found the solution for the problem I mentioned.
Just add to lines of Code to modify the properties of request object.
Delay in the in the initial call is reduced by setting the Proxy as null. This happened in all versions of windows.
request.Proxy = null;
Also, In Windows 7, If I send 10 requests, I am only getting 5 or 6 responses. By setting KeepAlive property to false, I am getting all responses.
request.KeepAlive = true;
Hope this helps someone! Happy Coding...
|
|
|
|
|
Hi All,
I am trying to convert a class object into a string of xml format using XmlSerializer.
My class structure is like this:
namespace test
{
public class Class1
{
public Class1(){}
private string strStatus = "Active";
public string Status
{
get { return strStatus; }
set { strStatus = value;}
}
public Class2 Class2 { get; set; }
}
public class Class2
{
public Class2(){}
private string strName = "ABC";
public string Name
{
get { return strName; }
set { strName = value; }
}
public Class3 Class3 { get; set; }
}
public class Class3()
{
ArrayList Element;
private int intCount = 0;
public Class3()
{
Element = new ArrayList();
}
public int Count
{
get { return intCount;}
}
public void Add(Class4 Entry)
{
Element.Add(Entry);
intCount++;
}
public Class4 this[int index]
{
get
{
return (Class4)Element[index];
}
}
}
public class Class4
{
public Class4(){}
private int intSub1;
private int intSub2;
public int Sub1
{
get {return intSub1;}
set {intSub1 = value;}
}
public int Sub2
{
get {return intSub2;}
set {intSub2 = value;}
}
}
}
Now, i am using this code for converting object of Class1 to a string of xml format:
Class1 objClass1 = new Class1();
Class4 objClass4 = new Class4();
objClass4.Sub1 = 68;
objClass4.Sub2 = 73;
objClass1.Class2.Class3.Add(objClass4);
Class4 objClass4Dup = new Class4();
objClass4Dup.Sub1 = 76;
objClass4Dup.Sub2 = 65;
objClass1.Class2.Class3.Add(objClass4Dup);
System.Xml.Serialization.XmlSerializer x = new XmlSerializer(objClass1 .GetType());
StringWriter sw = new StringWriter();
x.Serialize(sw, objClass1);
string strxml = sw.ToString();
MessageBox.Show(strxml);
In the messagebox, i can see values till Class2 properly in xml format.
Then i can see the "Count" of Class3 and its value, but the values of Class4 are not coming into string.
Can anybody tell what i am missing or what i need to do to display values of Class4 into string?
Thanks,
Nagendra.
|
|
|
|
|
Message Closed
modified 23-Nov-14 6:39am.
|
|
|
|
|
Hi,thanks for replying.
I am using Indexer for getting the indexed based value of Element.
|
|
|
|
|
Message Closed
modified 23-Nov-14 6:39am.
|
|
|
|
|
Thanks for replying.
I have solved it using the same property.
I just gave the xml attribute to the property definning its type and its working now.
|
|
|
|
|
Hi,
I added a public property for Element in Class3 as:
public ArrayList GetElement
{
get
{
return Element;
}
}
But i am getting an error as "An error occured while creating Xml Document".
|
|
|
|
|
Hi,
I make somethin like:
File.WriteAllBytes("C:\\test.TXT", mybytes);
FileInfo fi = new FileInfo("C:\\test.txt");
Now fi.Fullname returns the lower case FileName, but I need to get the correct cased file name.
Is there any way whithout doing a enumerate directory, and compare the strings?
Thanks
-- Daniel
|
|
|
|
|
Message Closed
modified 23-Nov-14 6:39am.
|
|
|
|
|
Not for windows but for Linux. And I comunicate by NFS with a Linux system.
|
|
|
|
|
Windows isn't case sensitive regarding file names.
Why do you need to find out the "correct" casing?
|
|
|
|
|
Calla wrote: Windows isn't case sensitive regarding file names.
Windows isn't but c# string comparison is. "abcd" is not the same as "ABCD", so if you are going to compare file names in your program, you have to get the correct case or it won't work.
|
|
|
|
|
|
Well, golly gee, Martha, what wonderful things they can do nowadays. Who would have thought of that?
|
|
|
|
|
Check out the overloads of String.Compare. You've got all kinds of options, including ignoring case, when comparing strings.
|
|
|
|
|
other operating systems may have case-sensitive file systems, Unix does.
When you want to use your app on such system, or you want to store data on a non-Windows external storage system, the app needs to take care of casing.
|
|
|
|
|
One does have to wonder, though, how the app would get an incorrectly-cased file name. I'd expect the user to enter in the filename with the correct case on an OS that could have two filenames that are the same aside from case. If it was a file created by the app, I'd expect the app to already know the filename.
Also, C# is rarely used on Unix systems (though, due to Mono, it can be used there). I wonder if the OP actually needs this functionality, or if the question was asked out of curiosity. Only in very strange instances do I see this as useful.
|
|
|
|
|
aspdotnetdev wrote: I'd expect the user to enter in the filename with the correct case
Most of the time the problem is the app runs on Windows and doesn't mind casing errors until you issue a file command to a Unix-based file server. Typically it isn't a file name clash, it is a no-such-file problem.
one way of getting in trouble is by having hard-coded extensions, say in OpenFileDialog filters, or in a Path.ChangeExtension() call.
|
|
|
|
|
It's even more complicated than that. Unix sees myfile.txt and MyFile.txt as two different files and lets you create these two files in the same directory, side by side. Windows doesn't like that and won't let you do it.
Most C# programs probably never have to interoperate between Windows and Unix. It's much more of a problem with something like Java.
|
|
|
|