Results 1 to 4 of 4

Thread: File IO in ASP.NET

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Toronto, Ontario, Canada
    Posts
    275

    File IO in ASP.NET

    Hey,

    I need to save a file to the server. The standard file io code doen't work.

    Please Help Me!

  2. #2
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Sure it does.

    You need to grant permission to the folder you are trying to write 2.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Location
    Toronto, Ontario, Canada
    Posts
    275
    can you post some example code

    mine (even after perm.) wont work..got it to work with windows forms only

  4. #4
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Here a code snippet I use on one of my pages to bind to a datalist control. I read in my image files from a directory within my web application:

    NOTE: Saving works the same way

    Code:
    private void LoadPostImages() 
    {
        string dir = Server.MapPath(ActiveUser.PathToPostImages);
        foreach (string img in Directory.GetFiles(dir, "*.gif")) {
            rblPostImages.Items.Add(new ListItem("<img border=0 align=absmiddle src=" + dir + Path.GetFileName(img) + ">&nbsp;", Path.GetFileName(img)));
    			}
        rblPostImages.Items.Insert(rblPostImages.Items.Count, new ListItem("none", ""));
        rblPostImages.SelectedIndex = rblPostImages.Items.Count - 1;
    }
    Last edited by Lethal; Jul 7th, 2003 at 03:10 PM.

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