Results 1 to 5 of 5

Thread: File extension

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2006
    Posts
    25

    File extension

    I must save a file with an extension of the type object.type.dat. How I make with savefiledialog?
    Thanks.

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Re: File extension

    VB Code:
    1. Dim cdlg1 As New System.windows.Forms.SaveFileDialog
    2.         Dim flnm As String
    3.         Try
    4.             If saveFileName = "" Then
    5.                 Do
    6.                     'Get it.
    7.                     cdlg1.FileName = ""
    8.                     cdlg1.Filter = "Function Files (*.FNC)|*.FNC"
    9.                     cdlg1.CheckFileExists = False
    10.  
    11.                     If cdlg1.ShowDialog() = DialogResult.Cancel Then
    12.                         Return False
    13.                     Else
    14.                         flnm = cdlg1.FileName
    15.                     End If
    16.                 Loop While flnm = ""
    17.                 saveFileName = flnm
    18.             Else
    19.                 flnm = saveFileName
    20.             End If

    This is an incomplete piece of a function I have to save a specific type of file. It won't work as is, because saveFileName is not declared (it is global), but it should give you some ideas.

    Notice that you cannot do quite what you want with the extensions: You can have .DAT appended automatically to any name, but that's all. To get the whole object.type.dat, you would probably want to just have object.type as the file name, and let the .dat be appended automatically.
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2006
    Posts
    25

    Re: File extension

    I have made therefore.
    If .ShowDialog = DialogResult.OK Then
    Dim name = .FileName
    Dim end = .FileName.LastIndexOf(".")
    fil = Mid(fil, 1, fine - 0)
    fil = fil & ".object.type.dat"
    .......

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Re: File extension

    That can be done. Is it working?
    My usual boring signature: Nothing

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Feb 2006
    Posts
    25

    Re: File extension

    Yes.I have used this system why I have analyzed pages web and me the system of the mid() has seemed useful.

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