lakkadghat Posted September 14, 2003 Posted September 14, 2003 heloo everyone i am facing error locating a file i am having two forms i am accepting a user's photograph in form one. after form one is saved and i open form two where i am access a text file which is located in the directory where the software exe is running but it searches the text file in direcoty where the jpeg was selected from. i think there is some initialisation problem. can any one help me or is there any command where i can tell it to read the file from current directory itself the cade that i am using is 'form1 Private Sub OpenPicDialog() Dim OpenDialog As New OpenFileDialog() OpenDialog.InitialDirectory = "D:\" OpenDialog.FileName = "" OpenDialog.DefaultExt = "jpg" OpenDialog.Filter = "Jpg Files(*.jpg)|*.jpg|Gif Files(*.gif)|*.gif" OpenDialog.CheckFileExists = True OpenDialog.CheckPathExists = True Dim ResultDialog As DialogResult = OpenDialog.ShowDialog() If Not OpenDialog.FileName.EndsWith(".jpg") And Not OpenDialog.FileName.EndsWith(".gif") And Not _ OpenDialog.FileName.EndsWith(".GIF") And Not OpenDialog.FileName.EndsWith(".JPG") Then MessageBox.Show("Please Upload JPEG & GIF Files ONLY", "At-Taiseer", MessageBoxButtons.OK) ElseIf ResultDialog = DialogResult.OK Then resumepic.Image = Image.FromFile(OpenDialog.FileName) strfilename = OpenDialog.FileName End If dim frm as new form2 frm.show me.hide End Sub 'OpenPicDialog 'form2 Dim sr As StreamReader Dim srmoze As String Dim arrldb() As String sr = New StreamReader("Ldb.txt") srmoze = sr.ReadLine() sr.Close() thanx in advance Mu$t@f@:confused: :confused: Quote
*Experts* mutant Posted September 14, 2003 *Experts* Posted September 14, 2003 As far as I know whenever you use the Dialog of that sort like OpenFileDialog, the location that you last used will be saved. Use this as a path: Application.StartupPath & "\ldb.txt" Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.