|
Thanks!
I tried the GetCommandArgs(), but arg 1 is only "C:\Documents"
I tried a few more args (2,3, etc) and found that everytime there is a space in the path, a new argumant is created. I checked and the %1 in the File Type Arguments Prperty is in double quotes.
Am I doing something wrong?
|
|
|
|
|
Check the File Type association in Explorer first. I'll bet that the quotes are missing. The symptoms you are running into (spaces dictate new argument) say that this is exactly what the problem is.
RageInTheMachine9532
|
|
|
|
|
Did you mean File Types in Explorer, or in the Argument Property of File Types in the Setup project of my application?
I checked both. In Explorer, the "Open With" application is my application, and the Argument Property in the Setup Project is "%1". Is there another explaination?
Thanks!
|
|
|
|
|
In Explorer...
Open an Explorer window, on say C:, and go to the Tools menu, pick Folder Options, and click on the File Types tab. Then scroll down to your file extension and click on it. Click on the Advanced button, then click on the Open action and the Edit button. In the "Application used to perform action:" box you should see something like this, but for your app:
C:\WINDOWS\system32\NOTEPAD.EXE "%1"
If the quotes are not around the %1, you'll run into the problem that your having.
RageInTheMachine9532
|
|
|
|
|
Thanks!
I looked as you suggested and the quotes are there. However, there are also quotes around the path to the executable that opens the application. I notice that there are no quotes around this path in your example. Should I remove these quotes in Explorer?
|
|
|
|
|
Nope. They stay there. When you test your app, put the quotes around the complete path in the Command line args under Project/Properties/Debugging. Opps! My bad.
RageInTheMachine9532
|
|
|
|
|
Thanks!
It works now. However, if you open the ap by double clicking on a file, then double click on another file, a second instance of th app opens. is there a way to just add a second MDI Child to the first app instead, or is this the expected behavior?
Thanks again, everyone has been very persistent and very helpful!
|
|
|
|
|
That's expected unless you code it otherwise. Your app is going to have to check for a previous instance that is already running. THis code cample is right out of the VB.NET docs:
' Visual Basic .NET
Function PrevInstance() As Boolean
If Ubound(Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess.ProcessName)) > 0 Then
Return True
Else
Return False
End If
End Function
You'll also have to write a mechanism so the app can communicate with another instance of itself. Look into Call Context or Asynchronous Remoting for some examples. They will look kind of wierd and you'll be wondering why your using http to send this stuff back and forth, but it's right. You'll be sending the full filename from the new instance to the old one.
RageInTheMachine9532
|
|
|
|
|
See Creating a File Association[^] in the Platform SDK on MSDN. Decent installers (like Windows Installer) can do this easily during installation of your application as well (in the case of Windows Installer, see the Extension, ProgId, and Verb tables). In you use a Windows Installer project within your solution for compiled projects, you can also click on the File Types Editor above the Solution Explorer when you select your installer project file.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi
I am creating a client server application in VB.net. client is calling a method in the server using a proxy class. I am throwing an exception on the server side. Now i want the client to capture that particular exception. How can i do that. I could able to achive this when i run both client and server on the same machine but when i run the client on the different machine I am getting an exception server generated and exception check the server's config. file. How can i catch the particular exception generated by server.
thank you
|
|
|
|
|
I want to Write a line into a existing Text file
Ex
Line1
Line2
Line3
I want to replace Line2 With NewLine2
How can I seek a particular Line (move to a given line & Replace it)
____________________________________________________________________
This is append the file but i want to edit the file
myProp = Value.Split(",")
Dim sr As StreamWriter = File.AppendText(FILE_NAME)
sr.WriteLine(myProp(0))
sr.WriteLine(myProp(1))
sr.WriteLine(myProp(2))
sr.WriteLine(myProp(3))
sr.Close()
_____________________________________________________________________
|
|
|
|
|
You can't replace just the one line without rewriting the entire text file. The reason for this is text files have records of varying lengths.
Imports System.IO
Imports System.Text
Dim srcFile As New StreamReader("SourceFile.txt")
Dim newFile As New StreamWriter("NewFile.txt")
Dim inText As String
Dim intLineCount As Integer = 1
inText = srcFile.ReadLine()
While Not inText Is Nothing
If intLineCount <> 2 Then
newFile.WriteLine(inText)
Else
newFile.WriteLine("New Text To Replace Line 2")
End If
End While
srcFile.Close()
newFile.Close()
File.Delete("SourceFile.txt")
File.Move("NewFile.txt", "SourceFile.txt")
RageInTheMachine9532
|
|
|
|
|
i dont think u can seek to a specific spot in the file to replace just that line, however, someone else should reaffirm this, or otherwise disprove it.
here, i took a little time just now and wrote a sub which will replace any line # in a file, with the string you desire:
<br />
Private Sub TextLineWriter(ByVal fileName As String, ByVal lineNumberToReplace As Integer, ByVal textToWrite As String)<br />
Dim inFile As IO.StreamReader = IO.File.OpenText(fileName)<br />
Dim tempString(-1) As String<br />
Dim i As Byte<br />
<br />
'read the file given and save each line into a new array element string<br />
Do Until inFile.Peek = -1<br />
ReDim Preserve tempString(tempString.Length)<br />
tempString(tempString.Length - 1) = inFile.ReadLine<br />
Loop<br />
inFile.Close()<br />
<br />
'determine if supplied 'numberToReplace' is valid with the current file,<br />
'and correct the problem if so<br />
If lineNumberToReplace - 1 > tempString.Length - 1 Then<br />
lineNumberToReplace = tempString.Length<br />
ElseIf lineNumberToReplace - 1 < 1 Then<br />
lineNumberToReplace = 1<br />
End If<br />
<br />
'write the 'textToWrite' at the line number given<br />
tempString(lineNumberToReplace - 1) = textToWrite<br />
<br />
'create same file as given (overwriting it) and rewrite the entire file<br />
Dim outFile As IO.StreamWriter = IO.File.CreateText(fileName)<br />
For i = 0 To tempString.Length - 1<br />
outFile.WriteLine(tempString(i))<br />
Next<br />
outFile.Close()<br />
End Sub<br />
use it like this: TextLineWriter("C:\myFile.txt", 3, "Here is my newly put text.")
no need to use Imports system.io for it, it is already specified in the sub.
just copy and paste this exact, as is sub and test it out. please lemme know if this helps.
------------------------
Jordan.
III
|
|
|
|
|
i wish to create a simple print function to print the content of picturebox or richtextbox through my printer... anyone can provide some simple codes?? i found codes from vb.net documentation but i really cant understand wat is that... any help is greatly appreciated...
|
|
|
|
|
I have 2 projects in my solution as seen in Solution explorer (VB.NET) - One is a windows app the other is a controls library used by the windows app. How do I get the windows app code to acknowledge changes in the controls library? If I add a new property to the controls library the windows app refuses to see it.
Rugby League: The Greatest Game Of All.
|
|
|
|
|
1) Did you rebuild the control library? References and intellisense won't work properly until you do.
2) Check the properties of the windows app to make sure the reference to controls refers to the proper place. When you move projects around, you can accidentally refer to an old version.
I hope this is of some help to you.
|
|
|
|
|
Thanks, it was caused by it copying the dll locally.
Rugby League: The Greatest Game Of All.
|
|
|
|
|
Hmm, now the control has disappeared from the form it was on and the compiler says "Could not copy temporary files to the output directory." and "The file 'xxx.dll' cannot be copied to the run directory. The process cannot access the file because it is being used by another process." This even happens if I quit Visual Studio and then run it again.
Any ideas?
Rugby League: The Greatest Game Of All.
|
|
|
|
|
I can't get this to work at all, on the reference to the controls in my main project if i say Copy Local = true then it won't compile because it says "Could not copy temporary files to the output directory." and if I set Copy Local = false then the main project doesn't pick up any updates I make in the controls project because it copies the dll into the "bin" directory of the main project once then doesn't update it if I make changes to the controls project.
Does anybody have a solution to this please? I am sure multiple projects in a solution are a good idea but I just can't get it to work at all.
Rugby League: The Greatest Game Of All.
|
|
|
|
|
In your Main project references, did you use a reference to the .DLL of your control project? Or did you set the reference using the 'Projects' tab? If you used a .DLL reference, go into the references folder of your main project and remove the reference.
In order for this to work, you will have to use 'Project' references. This requires that botyh projects are part of the same solution. This, also, will ensure that your dependent control projects are built up-to-date and will allow you to modify the control project, rebuild the solution, and see the changes in the main project.
RageInTheMachine9532
|
|
|
|
|
Excellent, thank you/
Rugby League: The Greatest Game Of All.
|
|
|
|
|
You might be referencing "controls library" assembly instead of its project
Regards,
Serge (Logic Software)
|
|
|
|
|
I am wanting to create a nice all in one program dealing with services. Basically what I want to do i enumerate all of the services on a given machine and be able to start, stop, restart or remove a service (in the instance that a past program didn't do it). I can do everything but remove the service. I know i can remove a service with installutil /u, but I'd rather do it programmatically as I'd rather just have one .exe file if possible for portability. Anyway, can this be done, and if so, how could i do it with vb.net?
Thanks for any help.
|
|
|
|
|
Hello,
How do I make the Hourglass show up in VB.NET while the code is executing? I am querying a database and it takes a while and i would like to have the hourglass show until the query is done.
Thank you,
Santana
|
|
|
|
|
Check out the Cursor property of your Form. You can change it to WaitCursor to get the effect you want.
RageInTheMachine9532
|
|
|
|