|
-
Aug 10th, 2003, 01:05 AM
#1
Accepting files
Okay, how can I make it so I can open a file WITH my program? It's a simple editor, how do I make it accept files?
-
Aug 10th, 2003, 03:32 AM
#2
Sleep mode
You probably need to use some API and registering the ext of your files in the reg . Very easy way is to use InstallSheild . It has the option to add this functionality while installing your app . It does all the work for you .
-
Aug 10th, 2003, 10:32 AM
#3
Originally posted by Pirate
You probably need to use some API and registering the ext of your files in the reg . Very easy way is to use InstallSheild . It has the option to add this functionality while installing your app . It does all the work for you .
I'm not even worried about registering my file, I want to know how my program can open a file if I select it and click open with...
-
Aug 11th, 2003, 01:24 AM
#4
you have to tell windows to pass the path to app and heres how you get it
VB Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strArgs() As String
Dim I As Integer
strArgs = Environment.GetCommandLineArgs()
'strArgs(0) the path to the exe
'strArgs(1) is the first arg
'strArgs(2) is the second arg ect.
For I = 0 To UBound(strArgs)
MsgBox(strArgs(I))
Next
End Sub
End Class
Tips:
- Google is your friend! Search before posting!
- Name your thread appropriately... "I Need Help" doesn't cut it!
- Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
- Allways Include the Name and Line of the Exception (if one is occuring!)
- If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)
If you think I was helpful, rate my post  IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous
-
Aug 12th, 2003, 03:45 PM
#5
Thanks, I can get it so I can right click and open files right into my program, however if I run my program normally, I get an error.
The 2nd arguement within the array is always the file's name and location, if I just run the program it will give me the location of my program's .exe. So as is, I can open other files into my program, I CANNOT just open the program by itself.
I have an If statement on my main form which declares fileInfo so I can get the extension, and then I used an if statement to check, if it's an exe, then it just opens, otherwise it opens the file into the text box.
VB Code:
Dim fileInfo As New IO.FileInfo(strArgs(1))
This works perfectly, except when the program is run normally, then it says this error:
Code:
Index was outside the bounds of the array.
I'm confused, how can I make this work, I figured a simple if statemenet to check to see if the program is either being run or was given arguements.
-
Aug 12th, 2003, 03:48 PM
#6
You should encapsulate the handling of any arguments within an If..Then block to first see if there are any arguments. strArgs(1) assumes there are arguments passed in which when you run it normally there aren't.
VB Code:
Dim strArgs() As String
Dim I As Integer
strArgs = Environment.GetCommandLineArgs()
If strArgs.Length>0 then
'Handle arguments here
Dim fileInfo As New IO.FileInfo(strArgs(1))
End If
-
Aug 12th, 2003, 03:53 PM
#7
-
Aug 12th, 2003, 03:53 PM
#8
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|