I'm making a program in which a couple of txt files will be used for reading and writing (streamreader/writer). Incidentally, these txt files might be in use by another program, although never more than 1 or 2 seconds each time.
Suppose, I have the following
Dim Input As New System.IO.StreamReader("c:data.txt")
Data = Input.ReadLine
...more code...
[Code].....
This doesn't work though. When I open c:data.txt in another process and run my VB application, I still get the IOException.
I would like it to check if the text file (myfile.txt) contains anything. [Code] but if I changed the myfile.txt with a value of "hello" and save it. I still get the "msgbox("myfile.txt does not contain any information")" What am I doing wrong?
Its been requested that my project has a way to limit number of users logged in at one time. I have that figured out but there is a problem. What I have done is that when a user logins in the application creates a .usr file in a directory on the network. If the number of users (value in the database) is less than the number of .usr files another user can log in, otherwise they can not(the file gets deleted at logout or application close). Now the problem is I need to create a way that if the .usr file get deleted the application will close. Is there a way to keep a watch on file and if it gets removed close the application.
would it be possible to check if any notepad or word file is open that contains the word 'test'?I was thinking something like the following.
Dim Process() As Process = System.Diagnostics.Process.GetProcessesByName("notepad") Dim Process2() As Process = System.Diagnostics.Process.GetProcessesByName("word") For Each p As Process In Process If p.MainWindowTitle.Contains("test") Then
I have a text file with user names in them on separate lines. I want to check to see if any of the lines doesn't match the exact text im checking for. It doesn't matter what line the text is on, as long as it is in there. If it's not, alert me. Previously i tried .contains() but obviously if a user name is "hello" and another's is "helloworld" it will match both of them.So basically i need to read all the lines in the txt file and if none of them lines contains the specific text im looking for then alert me. [code]
Is it possible to check a location for a file and if a file exists then create a new file (+1) in the file name? For example if there is no test file in the C:Temp folder then create a test.txt file and if there is one there then create C:Temp est1.txt and if there is a C:Temp est1.txt file then create C:Temp est2.txt and so on?
I was thinking If Not IO.File.Exists("C:Temp est.txt") Then IO.File.WriteAllLines("C:Temp est.txt" + 1, vbCrLf) End If
this is my very first posting and I must say I am desperate. I have a VB assignment due in 2 days and I am so lost. I have written a code to draw some graphic, just a basic house, tree, sun etc. I have also written a code to magnify said graphics which were all the specifications of my Assignment 1 part A. Now for Part B I am being asked to extend my program so that: A - My graphic can be drawn using different colour schemes designed by me but chosen by the user B - My graphic or an appropriate part of it can be animated around the picture box if the user chooses to do so. C - Error checking is included.
Our program will start with the help of a FileSystemWatcher object. How can we check or the file is total copied, for example the file is 100 Mbyte it take a time it's ready for use. Idea:
Do While True Try N = testForUse(BigFile) If N = 1 Then Exit Do
I've gone through about 16 hours and two packs of cigarettes trying to figure this out. First a little background. I was using 6.0 up until 2004 when I went to prison. I'm out now, and trying to relearn the trade, using VS 2005. I'm currently porting some 6.0 code from another project, SpyCast Webcam Studio, into VB 8.0. It's disheartening, to say the least. None of the old built-in subs/functions work anymore, so I have to scour the forums to relearn each and every function.The section I'm doing now takes a snapshot from the webcam (Video API --> PictureBox --> Save as Jpeg), then upens the file to upload it to the server via HTTP POST. I've been using this code in SpyCast for years with no trouble, but I spent many hours trying to piece together the right code to open the binary file to read its contents. I pieced together two methods I found around the forums, one using FileStream() though the code I found wasn't for binary files, even though it said it was, so that code doesn't really work. Method two uses Microsoft.VisualBasic.FileOpen() and works better.
Here's the kicker. By the time I run through the rest of the rigamarole of uploading the file, by the time I read it on the webserver, it's *slightly* corrupted. It's a valid Jpeg, no errors, but the picture looks like when I use to watch the Playboy Channel when I was a kid scrambled with weird colors and whatnot. [code] Each "chunk" is basically one "line" of the file. It looks like a single LineInput() return is the text between two carriage returns. Am I correct? I tested this with a flat text file, and it looks true. However, That one input line returns the text or data with the carriage returns *stripped*! ***?!? =( Fine, I have no problem adding my own vbCrLf to each LineInput(), if I were opening text. but this's binary. A character could be Chr(10) or Chr(13), both of which are removed from the original file contents.So I could very well need to use something other than LineInput(), but I haven't found any other examples on the web using this method.
A user exported a excel file and he opened it.Some reason, he tried to export same exel file as same name.Then, the application is gone because it does not know what do with it.How do I check the excel file is opned or not when I try to export as same file name again?
I have created a backup script which my organization uses to back up a specific set of data weekly, to a server, by clicking and running the app.I am always updating it/ improving it and instead of redistributing to the select employees there has to be a way to code in a "check for updates" type of thing.
I was wondering how to make my created app check with that server to see if i am running the latest version.
How do i incorporate a "version" in my app, or would it just be a naming convention thing? and how do i check for updates? Would a button being selected to check updates be preferable? or is there a way to auto detect it?
I have a DataGridView that contains a few columns of data. Is there a way to check a column for a value before i add a new row, just to make sure i dont put dupes in it?
i have a file with a serial number in it and i need to check if it is in sequence or not and then print a report stating no errors or if there is errors what line they are on.
I have a piece of code for a program where when a specific checkbox is checkedunchecked (In this case "Allyellow") it checksunchecks any checkboxes within a group of 14 with a lightyellow backcolor. While the piece of code below does this fine it seems to me to be very clunky and I know it's possible to streamline it any number of ways.
Yellow Check-boxes Private Sub Allyellow_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Allyellow.CheckedChanged If Allyellow.Checked = True Then
I have seem some threads similar to this but none have resolved my problem thus far.I currently have a gridview that is populated from a database table. There is a check box field within this table, generated from one of the fields being of Data Type "bit". When this page is loaded, the check boxes are grayed out and I am unable to click on them to change.