Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Manipulation problem!

Status
Not open for further replies.

JaneB19

Technical User
Jun 27, 2002
110
GB
Hi,

I'm hoping that somebody can help me!?!?!

It's a bit strange really because I don't understand why I'm getting the following error:

Name 'txtAttach' is not declared

I've tried just having the FileBrowser in the 2nd declaration (line of coding), because it's actually in <input type="file"> in the HTML side of the coding, but this didn't work which is why the 1st line in! Hope I've not lost anyone?!
Code:
    Dim FileBrower As String = txtAttach.Text
    
    Dim FilenameAndExtention As String = System.IO.Path.GetFileName(FileBrowser.PostedFile.FileName)

    Dim IndexOfDot As Integer = FilenameAndExtention.LastIndexOf(".")

    Dim FilenameOnly As String = FilenameAndExtention.Substring(0, IndexOfDot)

    Dim ExtentionOnly As String = FilenameAndExtention.Substring(IndexOfDot + 1, FilenameAndExtention.Length - IndexOfDot - 1)

    Dim LocationToSave = Server.MapPath("~/Attachements/")

    FileBrowser.PostedFile.SaveAs ( LocationToSave + FilenameAndExtention)

    Dim DataLocation As String = ( LocacationToSave + FilenameAndExtention)
Does anybody understand/know why this error message is occurring?

Any ideas or pointers would be great!

Thanks in advance

Jane
 
use Server.MapPath(FileBrowser.PostedFile.FileName)
 
Thanks for your reply DaZZleD.

Unfortunately I get the same error message!

Any more ideas?

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top