CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2001
    Location
    Iceland
    Posts
    1

    Open files in Windows

    I made program to view 'log' files. But I don't know how to open it in my program by double-clicking it in Windows(98)

    Can someone please help me??
    (The one that will help me will get free football game that I made


  2. #2
    Join Date
    Dec 2000
    Posts
    163

    Re: Open files in Windows

    There is two ways:

    1. Open the file in NotePad use that code:

    private Sub OpenFile(sFileName as string)
    Shell "Notepad.exe " & sFile, vbNormalFocus
    End Sub




    2. Open the file into some TextBox in your program. You have to Use FileSystemObject Try this Code:

    private Sub OpenFile(sFileName as string)
    Dim ObjFileSys as new Scripting.FileSystemObject
    Dim ObjFile as Scripting.File, ObjStream as Scripting.TextStream
    Dim strFile as string

    'get the file
    set ObjFile = ObjFileSys.GetFile(sFileName)
    set ObjStream = ObjFile.OpenAsTextStream(ForReading)
    strFile = ObjStream.ReadAll
    'Show the file in the textbox
    Text1.Text = strFile
    End Sub




    I hope it help you.
    Notice me if is (or not).

    Don't forget the football game !!!


  3. #3
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: Open files in Windows

    You need to "Associate" the filename .log with your application.

    First make sure your app accepts the filename as a command line parameter.
    Then in Explorer choose the View:Options menu,
    switch the resulting box to File Types and press the New Type button to create the new association.
    Once this is set up then double-clicking a .log file will launch it with your application.

    HTH,
    Duncan

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--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
  •  





Click Here to Expand Forum to Full Width

Featured