|
Wowow relax, you could just ignore him you know
I also went out of my way to look for a solution, but it is indeed hard to find - I eventually found some highly obfuscated C code that is "supposed to" do what you want.. but the links given earlier are probably better anyway.
|
|
|
|
|
You'll have to excuse my snappy reaction before, but I want to shoot down a spin-off debate on this topic on 'the validity of it all' before it gets a chance to start.
I reckon you're right on the earlier links however.
Unless someone has some knowledge on my WMI + C# question I posted as a reaction to said post.
Fingers crossed.
|
|
|
|
|
I didn't have a problem with what your question was.
I was just saying why you see that discussion all over the web and noone really answering the question.
|
|
|
|
|
Fair enough.
And it's something I see more often.
But it's not up to others to decide the validity of the question.
A question was asked, why not answer it and then ask why someone is asking it, if one is truly interested?
I can understand why some would feel frustrated with the ivory tower some developers are hiding in.
The relevance of a question can only questioned by the one asking it, imo.
|
|
|
|
|
The reason there is always a debate on why this is a valid question, in my opinion, is that 90% of the time it is the programmers actual program that is holding onto the file by not disposing of its resources before trying to delete the file.
So when your users want to know what is locking a file, are they going to see that it is another part of your code?
|
|
|
|
|
I see your point.
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.
It's much more effective if a developer is forced to assume responsibility for oneself,with the shaming conclusion that the developer in question needs to kick one's own behind.
My point being, give what is asked for and engage in conversation as to what the context is.
It'll result in a more social event that way.
And as to answer your question, I think that what the user is going to see, is that they still have something like Ultra Edit/Notepad/etc... is still holding the file and they forgot to close the text editor before testing/running their application.
If the question is:"Is it likely to be something silly?", the answer is most likely yes.
In the end, however, that's besides the point.
I'd prefer they'd find out for themselves in an easy way, instead of them having to bother me.
I'm all for self-reliance.
|
|
|
|
|
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.
|
|
|
|
|