|
You can accomplish the same goal by going to the Project settings, view the Application Tab, and make sure the checkbox that says Make single instance application is checked. Now only one instance of your application can run at a time. Also, if you want to, you can View the Application Events and add and event called the MyApplication_StartupNextInstance. You can add code here to perform a specific task if a user tries to run the application more than once.
Hope this helps.
|
|
|
|
|
My app is being called by a service and isn't really Form based at all. I currently don't have the application framework enabled. This suggestion was great... I didn't know this feature existed, but I'll try it another day on a different app which is more based around forms. Thanks!!
Lost in the vast sea of .NET
|
|
|
|
|
File.Create does not just create a file, it also opens it and returns a reference to the created FileStream .
Try this:
Dim MyFile As FileStream = File.Create(My.Settings.strFileName)
You can then use MyFile to add text. When you are done, call
MyFile.Close
File.Delete(My.Settings.strFileName)
|
|
|
|
|
Thanks!!! That worked perfectly!
Lost in the vast sea of .NET
|
|
|
|
|
If you're using a file to prevent a second instance from being opened, you have a problem. This won't work in all cases since you can have two instances of your app both checking for the existance of the file and both trying to create the file at the same time.
A better solution is to create a Mutex instead. A file can be created by multiple processes at the same time. A Mutex cannot. If two processes try to create the same mutex as the same time, one of them is forced to wait until the other request completes.
Documention on the Mutex class can be found here[^]. Just be sure to read it and to release the Mutex when your app is done with it.
|
|
|
|
|
Thanks! That does sound like a better solution! I'll look into it.
Lost in the vast sea of .NET
|
|
|
|
|
Hi all.
I wrote a directory watcher to monitor a folder for any changes. It works fine when monitoring a local folder and also a folder on the network as long as it's on a windows server.
As soon as want to monitor a samba share(Linux server) it doesn't work.
I am using the "filesystemwatcher" and from what I've heard it only works on a NTFS file system.
Is there a work around for this?
Thanx in advance.
|
|
|
|
|
There is a something you can try, but it doesn't work as good as the normal options the FSW uses:
Dim watcher As new FileSystemWatcher(folder, True)
watcher.setStrategy(Win9xWatcherStrategy.class)
|
|
|
|
|
Thanx for the fast reply.
I take it I need to use "Import System.IO"? And instead of "folder" use the directory?
It complains about "setStrategy" and "Win9xWatcherStrategy"
Do I need to declare it?
|
|
|
|
|
Whoops. My bad - that's only good in Java, not the .NET Framework.
There is no equivilent for the .NET FileSystemWatcher.
There is no known workaround to get the FSW to work with a Samba server properly. The FSW only works properly with NTFS partitions.
|
|
|
|
|
Well thanx for your help.
Isn't there something I can use instead of FSW?
|
|
|
|
|
There is no other component that does anything close to what the FSW does.
I don't know of any 3rd party copmonents that do it either.
When faced with such a situation, I woud just "roll my own" component. you'd have to poll the folder you want to monitor every so often, getting all the filenames and their modified dates. Then, on the next pass, fire off events for any files that have been added or changed since the last pass. Repeat ad nauseum.
|
|
|
|
|
Not tried it myself, but as a work-around, you could (ff you have access to the Linux machine) use inotify to detect file changes and send them to your application over your network.
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
I have a shared variable of sub report in main report. I want to sum it.
|
|
|
|
|
You should store the values in database then use function for Sum of Field.
If you can think then I Can.
|
|
|
|
|
Hello Every Body,
I have a listbox in which have 20 items. But when i want to get number of items in Timer. But it displayed 0.
If you can think then I Can.
modified on Tuesday, April 6, 2010 3:49 AM
|
|
|
|
|
Are you going to finish your sentance and ask a question?
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
Yes Please check
If you can think then I Can.
|
|
|
|
|
eg_Anubhava wrote: Yes Please check
I did, and select isn't broken.
eg_Anubhava wrote: I have a listbox in which have 20 items. But when i want to get number of items in Timer. But it displayed 0.
Try explaining something more. Did you create the items before you started the timer? Does the list "display" 0 items or does it "contain" 0 items?
Can you post your code here?
I are Troll
|
|
|
|
|
Hello Everybody,
Can any one explain it what is Flickers in vb.net. My friend suggest it Flickers is new concept of vb.net.
If you can think then I Can.
|
|
|
|
|
eg_Anubhava wrote: Can any one explain it what is Flickers in vb.net. My friend suggest it Flickers is new concept of vb.net.
No, it's not. Never heard of it. Ask your friend to explain what he means.
Google results for "vb.net flickers[^]".
|
|
|
|
|
Hi, i wanna make a bot, but i don´t know if it is possible to pass a value from a variable to a input text, through a WebBrowser. For example, use this bot to write a question in this site, the bot would be able to fill this message input! So, is it possible, and how can i do this using vb.net? thank you
|
|
|
|
|
ok, i think i solved it, i didn't had time to test it, but i found a code like this: webbrowser1.document.all.fieldname.value = TextBox1.Text
update:
the prewier code is just valid on vb6, for .net users the correct code is:
WebBrowser1.Document.GetElementById("fieldnam").InnerText = TextBox1.Text
modified on Monday, April 5, 2010 4:00 PM
|
|
|
|
|
Hello all
I wrote all of this stuff here Duplicate Files Finder[^] before I just saw that here are message boards and my questions aren't really much related to the Duplicate File Finder project.
Duplicate File Finder is a nice fast program and partly doing what I want to be done.
But I'm browsing the www for a few days now, trying to find a solution for my problem.
My current selfmade "solution" works, but as you will see, it's kinda simple and uncomfortable.
So maybe someone can help or give hints, that would really be appreciated.
I want to do this:
I have a folder with pictures I want to keep (that folder has different sub folders).
So I found hashdeep and use it to hash the files in the keep folder + subfolders and let it save the hashes in a txt file (hashes keep.txt). I use a batch file for that, the content changes so I have to re-hash after some time. Each line looks like this:
filesize,md5hash,sha-256hash,filename
Next I have a folder full of new pictures.
When I sort them, I sort out pictures I don't want to see again. So I use hashdeep to make another txt file database with hashes/files I don't want to see anymore when sorting files.
Then, everytime I get new pictures I use hashdeep to compare the new files with the 2 hash tables (using a batch file). It creates a text file containing the (full) file names of the found duplicate files in the new pictures folder. After that I use a batch file to open that text file and line by line delete each file listed in it, then delete the text file.
After that the new pics folder might still contain duplicate files. So I found HashMyFiles. It's kinda slow compared to eRRaTuM's Duplicated Files Finder and it processes all files without ignoring the files that exist only once in the new pics folder.
I use it to check the previously "cleaned" new pictures folder for double files. HashMyFiles gives each group of duplicate/multiple files an index and lets you sort by it. So I select all entries (except 1) of each group by hand and delete them.
After this the new pics folder contains only different files I might want to keep and files I don't yet have in my hash table file.
After sorting these pictures, I create new hashes of the new unwanted files with hashdeep and save to a new text file. I use a batch file to remove the 4 or 5 hashdeep info lines at the beginning of the file (creating a temp file, skipping the 1st lines, adding the new hash text file line by line to the temp file) and then add it (copy /B a + b ab) to the current hash table file after making a backup copy of it first.
And this game starts anew when I get new pictures.
So then I found eRRaTuM's program here on code project. It worked quite good, but for some reason I can't use it anymore after 1 day because I get a System.IO.FileNotFoundException when I want to process a folder. I don't know what causes this. It also would be just a better/faster replacement for HashMyFiles.
Sadly I don't know C# or C++, all I know is a little bit of VB.net. I just wrote me an image viewing/sorting program in VB.net, it works like I want it to, but I never learned how to code/script, so I'm kinda looking at other code like a sheep ;D
Is it possible to find an easy solution for all of this and maybe "import" the existing hashdeep hashtable files? I guess all I need might be the filesize (if needed for quicker comparison?) and the sha-256 hash, filename and md5 hash should be obsolete IMO.
Here again the options I want to achieve in a single program:
- compare files in a folder with informations in 2 hash databases, being able to list and delete found files with same hash in these databases
- look for duplicate files in a folder and list these found duplicate files, select all except one of each group (like Duplicate Files Finder does) and then delete them
- hash new files from a folder (the ones I don't want to see again after sorting) and add them to existing hash database
and maybe
- check existing hash database for double entries (which shouldn't be there though, but it wouldn't be bad to have such an option)
the more files I have in the new pictures folder and the more hashes in the database, the slower hashdeep becomes. I don't know if it's easy possible to make the new program use more threads/cores but that would speed things up I guess.
While looking for a solution I found code snippets and how to md5-hash files (I'd like hash-256 though since I already have these hashes and it means less collisions) but I have no idea how to get all of this done It's like a puzzle for me, snippets and no idea how to combine them.
Thanks for any advice/hint/place to look/other place to ask for help!
Nik
|
|
|
|
|
Imports System.Collections
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim airports As New Hashtable
airports.Add("JFK", "John F. Kennedy, New York")
airports.Add("LAX", "Los Angeles International, Los Angeles")
airports.Add("ORD", "O'Hare International, Chicago")
airports.Add("LHR", "Heathrow Airport, London")
MsgBox(airports.Item("JFK"))
End sub
Checkout for more you can do Retrieve All Values Sort & Iterate,etc...
http://www.java2s.com/Tutorial/VB/0160__Collections/0260__Hashtable.htm
|
|
|
|