|
To delete files, use: My.Computer.FileSystem.DeleteFile("C:\File_To_Delete.txt")
You can also select whether you want the file you are deleting to goto the recycle bin or just to be permanantly deleted. Just use:
My.Computer.FileSystem.DeleteFile("C:\File_To_Delete.txt", FileIO.RecycleOption.DeletePermanently)
|
|
|
|
|
try this
imports system.io
Dim objDir As New DirectoryInfo("C:\testdel")
objDir.Delete(True)
|
|
|
|
|
I am using VB.net 2005 express and I have created a dataset with SQL server 2005 express. I want to use that dataset to load the nodes in a treeview control. The dataset consists of two tables one is called the State table and the other is called the City. I want the State table to be parent nodes and the corresponding city table rows to be child nodes beneath it. Does some know how to do this?
Thanks.
|
|
|
|
|
hi, are you guys know how to insert an image into textbox / richtextbox
just like chat application (like this), with vb.net coding?
thanx guys!!!
|
|
|
|
|
Not sure about richtextbox, but a plain textbox, you can't, not without owner drawing, and as a textbox paints itself outside of WM_PAINT, that's a major headache.
So, I'd have to assume the RTB does support it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
okay, thanx ! i already find out (using clipboard and dataformats)
|
|
|
|
|
I'm trying to control navigation in one application from another application.
I can control almost anything but navigation.
Forexampel the following is completely ignored by the receiving application:
SendMessage hwnd, WM_KEYDOWN, VK_TAB, &HF0001
SendMessage hwnd, WM_CHAR, VK_TAB, &HF0001
SendMessage hwnd, WM_KEYUP, VK_TAB, &HC00F0001
(values obtained with Spy++)
but
SendMessage hwnd, WM_CHAR, Asc("b"), 0
is accepted.
What am I missing ?
Kenneth
-- modified at 11:56 Sunday 8th October, 2006
|
|
|
|
|
Hello,
I found a good solution using clickonce, for detecting if the application is first run. Using the following code:
<br />
If (System.Deployment.Application.ApplicationDeployment.CurrentDeployment.IsFirstRun)) Then Dim setConnection As New ServerSettings() setConnection.Show() Else Dim logMeIn As New Login() logMeIn.Show() End If<br />
However, the customer has just changed their mind. And they they want to specify the location of where they want to install the application. Clickonce only has a default that cannot be changed.
So I using the ms installer. However the above code does not work for it. It seems
I would like the serverSettings to run only on first startup. However, I am not sure about the code for this, as the above does not work.
Does amyone know the synstax for 'first run' when using ms installer?
I think I am destined not to get this finished, with the customer changing their mind.
Many thanks for your help,
Steve
|
|
|
|
|
You could store a key in the registry after you've run the serverSettings, and check it prior, so it only runs when they registry key is not set.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hello,
Thanks for your help.
Do you know of any examples that allow you to enter a key into the registery.
Thanks for your help,
Steve
|
|
|
|
|
I'm using Vb.net.
How to make a timer to read mouse cursor position on the form? I know how to use MouseMove event but it won't fire if mouse cursor is still. I would like to have a timer that would constantly report what are the current cordinates of the cursor.
|
|
|
|
|
Cursor.Location is, from memory how to find this out. But, I don't get why you'd do this. When the cursor moves, you can store the value or otherwise interact with it. When the cursor isn't moving, the value isn't changing, so why do you need to keep asking for it ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
when i click button of my app then this messege appear in immediate window:
"A first chance exception of type 'System.IO.IOException' occurred in mscorlib.dll"
and the function doesnt work and when sometimes this messege not appear then function work
someone know why it is coming?
|
|
|
|
|
There is an error in some file operation. What does the function do? Does it involve any file operations?
---
b { font-weight: normal; }
|
|
|
|
|
this is the function
Private Function SaveFile() As Boolean
Try
Dim value1 As String = Text1.Text
Dim fName As String
If lblmsg.Text = "IPL NOT LOAD" Then
Save.ShowDialog()
fName = Save.FileName
If Save.FileName <> "" Then
Dim fSave As New StreamWriter(fName)
fSave.WriteLine("# File Created By ABC")
fSave.WriteLine(value1)
fSave.Flush()
fSave.Close()
lblmsg.Text = fName
lblmsg.TextAlign = ContentAlignment.MiddleLeft
lblmsg.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!)
savechk = False
End If
Else
fName = lblmsg.Text
Dim fSave As New StreamWriter(fName)
If InStr(Text1.Text, "# File Edited By ABC") = True Then
fSave.WriteLine(value1)
fSave.Flush()
fSave.Close()
lblmsg.Text = fName
lblmsg.TextAlign = ContentAlignment.MiddleLeft
lblmsg.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!)
savechk = False
ElseIf InStr(Text1.Text, "# File Created By ABC") = True Then
fSave.WriteLine(value1)
fSave.Flush()
fSave.Close()
lblmsg.Text = fName
lblmsg.TextAlign = ContentAlignment.MiddleLeft
lblmsg.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!)
savechk = False
Else
fSave.WriteLine("# File Edited By ABC")
fSave.WriteLine(value1)
fSave.Flush()
fSave.Close()
lblmsg.Text = fName
lblmsg.TextAlign = ContentAlignment.MiddleLeft
lblmsg.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!)
savechk = False
End If
End If
Catch
End Try
End Function
|
|
|
|
|
You are catching the exception and ignoring it. Never do that! (Notice the exclamation mark that I used. I use less than a dozen per year, so when I do, they mean something.) If you don't know what to do with it, just throw it again, so that some higher level of the program can catch it.
Also, your error handling doesn't make sure that the files are closed if an error occurs. I believe that the error message that you see comes from some other part of your program when it tries to use a file that has been left open by the function.
Use Try and Finally to make sure that the files are always closed:
Dim fSave
Try
fSave = As New StreamWriter(fName)
fSave.WriteLine("# File Created By ABC")
fSave.WriteLine(value1)
Finally
If not fSave is Nothing Then
fSave.Close()
End If
End Try
You can add a Catch section before the Finally to handle any exception that occurs in this specific part of the code, or wrap all the code in the function inside a Try ... Catch to take care of any exception that occurs anywhere in the function.
---
b { font-weight: normal; }
|
|
|
|
|
no man its not the problem , listen the whole story
i write any text in richtextbox and click on save button which connected to that function, save file properly. but when i open that file again and edit and save again then this error occurs , so im sure that this codes are correct in the fuction:
Dim value1 As String = Text1.Text
Dim fName As String
If lblmsg.Text = "IPL NOT LOAD" Then
Save.ShowDialog()
fName = Save.FileName
If Save.FileName <> "" Then
Dim fSave As New StreamWriter(fName)
fSave.WriteLine("# File Created By ABC")
fSave.WriteLine(value1)
fSave.Flush()
fSave.Close()
lblmsg.Text = fName
lblmsg.TextAlign = ContentAlignment.MiddleLeft
lblmsg.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!)
savechk = False
End If
i think the error occurs in these codes
Else
fName = lblmsg.Text
Dim fSave As New StreamWriter(fName)
If InStr(Text1.Text, "# File Edited By ABC") = True Then
fSave.WriteLine(value1)
fSave.Flush()
fSave.Close()
lblmsg.Text = fName
lblmsg.TextAlign = ContentAlignment.MiddleLeft
lblmsg.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!)
savechk = False
ElseIf InStr(Text1.Text, "# File Created By ABC") = True Then
fSave.WriteLine(value1)
fSave.Flush()
fSave.Close()
lblmsg.Text = fName
lblmsg.TextAlign = ContentAlignment.MiddleLeft
lblmsg.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!)
savechk = False
Else
fSave.WriteLine("# File Edited By ABC")
fSave.WriteLine(value1)
fSave.Flush()
fSave.Close()
lblmsg.Text = fName
lblmsg.TextAlign = ContentAlignment.MiddleLeft
lblmsg.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!)
savechk = False
End If
End If If
|
|
|
|
|
I still believe that's the problem. Especially as you say that the error occurs the second time you use the function.
I showed you how to use proper error handling on the saving part of the code, but not because it's only there you should use it. You should use it on any file operation.
You have no indication of whether the function is working properly or not, as you are ignoring any exceptions that occur. At this stage you have no idea where the error actually is. Start by removing the Try ... Catch so that you see where the error occurs. Then you can correct the error and add proper error handling.
---
b { font-weight: normal; }
|
|
|
|
|
yeah man but you showed me only first/half code,
man i dint said that error coming on second time but i said sometimes it come sometimes not
|
|
|
|
|
xmen_xwk wrote: yeah man but you showed me only first/half code,
I showed you how to do it. I based the example on your code, but perhaps I should have made a completely different example.
xmen_xwk wrote: i dint said that error coming on second time but i said sometimes it come sometimes not
Actually you have said both. Anyway, you have to locate the source of the error before you can do anything about it, regardless of when it appears.
---
b { font-weight: normal; }
|
|
|
|
|
i made an application that looklikes a notepad so i want when i click on any txt file then mine notepad should open
|
|
|
|
|
if u have XP then goto control panel -> folder options -> view -> file types - > scroll down to txt file and click change.
Nathan Lindley
|
|
|
|
|
yeah man i know this , my application open perfect but it not open the text in file
|
|
|
|
|
Your app will be passed the name of the file to open as a parameter, you need to recieve this value and open this file. It doesn't happen magically, you need to grab the parameter and use it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
You're app has to be written to handle command line parameters. Check out the Environment class and its <a href="http://msdn2.microsoft.com/en-us/library/system.environment.getenvironmentvariable.aspx">GetCommandLineArgs</a>[<a href="http://msdn2.microsoft.com/en-us/library/system.environment.getenvironmentvariable.aspx" target="_blank" title="New Window">^</a>] method.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|