|
thanks pete, bt the was no need for you to be rude, u should have just pointed out the mistake
|
|
|
|
|
dbongs wrote: u should have just pointed out the mistake
I did. I don't have the time, inclination, or patience to coddle people who can't even be bothered to pick the correct forum.
|
|
|
|
|
ha ha hah hah hic - he though THAT was rude, wait till he post a programming question in the Lounge. I thought you were very restrained and most polite.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Posting anything in the Lounge is a dangerous game ...
|
|
|
|
|
Mycroft Holmes wrote: wait till he post a programming question in the Lounge.
...or until *I* see it here...
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Pete
I am sorry if i have offended you....please accept my apology, and thanks for your 1st msg, it encouraged me to get my error working.
|
|
|
|
|
Excellent attitude. Good for you, and a 5 for yourself.
|
|
|
|
|
dbongs wrote: thanks pete, bt the was no need for you to be rude, u should have just pointed
out the mistake
0) Yeah, there evidently is. First, you posted your question in the wrong forum. How anyone could miss the great-big C# at the top of the page is freakin' beyond me. If this is an example of your attention to detail, you're going to fail as a programmer, and you may as well find something else to do with your time.
1) Yeah, there evidently is. We spend all day in here answering questions for people, and when people ignore the possiblity that our answers to their question might have actually helped someone else if it had just been posted in the correct forum, it kinda ticks us off because now, we have to field the question AGAIN.
2) Yeah, there evidently is. Using text-speak is one of the fastest ways I know of to tick off the users here. If you can't take the time to type out a complete freakin' word, why should we take the time to answer your question?
3) Using the cute little angry smilie is beyond pointless. That in and of itself is what prompted me to respond to your statement.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
dbongs wrote: u should have just pointed out the mistake
He just did.
|
|
|
|
|
You should ask this question in a Jquery forum.
|
|
|
|
|
thanks Bob, i posted it on the Javascript forum.
|
|
|
|
|
Hello!
I want to know if file is being used by another process and wait until it's free.
I'm using the following code:
public static bool FileInUse(string path
{
bool blnReturn = false;
FileInfo file = new FileInfo(path);
System.IO.FileStream fs;
try
{
fs = System.IO.File.Open(file.FullName, FileMode.OpenOrCreate, FileAccess.Read, FileShare.None);
fs.Close();
}
catch
{
blnReturn = true;
}
return blnReturn;
}
) ;
But, instead of returning a value, the programm is crashing in
fs = System.IO.File.Open(file.FullName, FileMode.OpenOrCreate, FileAccess.Read, FileShare.None);
What is wrong here?
|
|
|
|
|
Are you running in a debugger? They will often notify you of exceptions even inside a catch. If you run this application on its own that should work, though it has a couple of issues (you will create the file if it doesn't exist, and you should be catching the specific exception you are looking for if you are just trying to find if the file is locked by another app).
|
|
|
|
|
Thanks a lot!
I runned the app by its own as you told, and that worked!
modified on Thursday, April 21, 2011 5:38 AM
|
|
|
|
|
Welcome.
You should be able to press Continue or similar (it's F5 in the debuggers I know) when you get an exception breakpoint inside a try when running in the debugger, by the way. You can also set your debugger not to notify you of caught exceptions.
|
|
|
|
|
I use this function,
private static bool FileInUse(string path)
{
FileInfo file = new FileInfo(path);
FileStream stream = null;
try
{
stream = file.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None);
}
catch (IOException ex)
{
return true;
}
finally
{
if (stream != null)
stream.Close();
}
return false;
}
although it will only return true if the file is Locked by another application(or yours). If the other application has opened the file without locking it will return false. You should be careful with your implementation as if the file is not found it would create one.
...and I have extensive experience writing computer code, including OIC, BTW, BRB, IMHO, LMAO, ROFL, TTYL.....
|
|
|
|
|
Thanks for the answer.
I will change "FileMode.OpenOrCreate" to "FileMode.Open" as you said.
The oly problem that was causing the program crash was I was running it in debug mode.
I have runned it by its own as BobJanova advised, and now it is working fine.
|
|
|
|
|
Unfortunately, your method and the method below does not work. If you place a lock on the file you have to wait for the O.S. to release the file. Thus a call FileInUse that returns true can still fail on the file open. The only way is to open the file and lock the file and return that lock.
|
|
|
|
|
Does anyone know how to get an attached database to store data permanet?, and if so please help me out with some links.. 
|
|
|
|
|
Why don't you let us know what database you are using, and what do you mean by permanent. Is the database losing data when you close the app, or when you install updates to the application or when? When asking a question you need to be pretty specific as to what the problem is and you might get more help.
...and I have extensive experience writing computer code, including OIC, BTW, BRB, IMHO, LMAO, ROFL, TTYL.....
|
|
|
|
|
But I get the data from the database and make changes and when I reopen the application the changes are not there, they always were when I used Access why doesn't the information stay in the database, I type it into the form!
[note the joke icon]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Wayne the database is loosing data when ever i close the application, and m using vstudio 2008 and sql2005
|
|
|
|
|
The reason that it's doing this is because you have a master version in your solution, and it is set to be copied to the output directory whenever you build the application. This means that you are making changes to your data when the app is running and then losing them when the master overwrites it. Take a look at the Copy to output directory property on the local database file.
|
|
|
|
|
Could you provide code? Are you actually sure that the data is being "stored" in your SQL tables. My theory is that it is not writing to the DB. Can you post your code where you write to the DB?
Craigslist Troll: litaly@comcast.net
"I have a theory that the truth is never told during the nine-to-five hours. "
— Hunter S. Thompson
|
|
|
|
|
Hi all,
I have developed an application in c# and made the setup and deployment.
But the problem is that in any system when i install my application i want to display my application name when you right click on any file or folder.
For example when you install WinZip and the right click on any file you see a option Add to Winzip,...etc.
Similar function i want to do for my application.
How can i do it ?
Thanks in advance.
|
|
|
|