Visual Basic/Files

Advertisement


Question
Dear Vitaly

I  have  a  problem when  i  save my file at  the Dialog box ask me for extension  
Example. I want to save the name, [ dim ]  when I press, [ Save ] whrite (This file name is invalid) If I write [ dim.txt ] is ok. Haw I can make code so I write only the name, [ dim ] and to be Valid.



Private Sub SaveFileToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveFileToolStripMenuItem1.Click


       Dim FileWriter As StreamWriter
       Dim results As DialogResult
       SaveText.DefaultExt = ("C:\vbFiles.txt")
       results = SaveText.ShowDialog
       If results = DialogResult.OK Then
         FileWriter = New StreamWriter(SaveText.FileName, False)




Thanks for the help
   
  Dimitris

Answer
Dear Dimitris,

Looks like problem is this statement:


      SaveText.DefaultExt = ("C:\vbFiles.txt")

It is defining Default extension as 'txt'. My suggestion is do not use this statement and see what happened.

If this didn't help, please, send me what is 'SaveText'? Is it control? How you define it?

(In your code sample there is no information about this 'SaveText'.)

Regards,

Vitaliy  

Visual Basic

All Answers


Answers by Expert:


Ask Experts

Volunteer


VITALY

Expertise

Area of expertise is Visual Basic .NET (VS 2008 and Framework 3.5) design and development for Windows applications. You can ask me any Visual Basic questions and some questions about .NET Framework. You can also ask me how to use Component One controls in Visual Basic. Do not ask me questions about Web design and development in Visual Basic.

Experience

I'm working as VB programmer from 1997, so I have a lot of experience with Visual Basic .NET as well as Visual Basic 6. Area of expertise is Visual Basic .NET (VS 2008 and Framework 3.5) design and development for Windows applications; Component One controls for Visual Basic; User controls; Moving VB6 applications to .NET.

Education/Credentials
B.S. in Computer Science

©2016 About.com. All rights reserved.