.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

FileUpload.SaveAs is configured to require a rooted path. but "http:// --- is not a rooted path

Posted By:      Posted Date: August 25, 2010    Points: 0   Category :ASP.Net

Hi Friends

when i am uploading image to http://filepath i got the 

The FileUpload.SaveAs Method is configured to require a rooted path but http:// filepath is not a rooted path

my code is as follows

If (Fileupload.HasFile)


Dim filepath As String = http://filepath/

FileUpload.SaveAs(filepath & String.Format("datafield_{0}_b.jpg", textbox.Text))

End If

Please help me




View Complete Post

More Related Resource Links

FileUpload Class SaveAs, how can you overwrite?

Hello all,

I'm trying to use 2.0 class, FileUpload. 
Namespace: System.Web.UI.WebControls
Class FileUpload

Anyway, in my code can save the file to the server

FileUpload1.SaveAs(SavePath + FileName)

Problem is I can't find a way to overwrite the file.  When I try and run the program again is says the file is already in use that a process has access to it.

Is thre a proper way to release control of whatever it grabbing hold of it?  In .Net I don't have to destroy my objects right?
Or is there a way to specificly overwrite the file? It seems that SaveAs does that.  Just trying to figure out why I can upload this text file, but sometimes only once and then I have to code in to check to see if it exists then rename it.

Get Full Value of Fileupload path

Hi, I have a file upload control on my webform. When I want to use it to select a text file. I will not be uploaded the file however, I will need the value of the path so I can open the text file with the streamreader. I then will pass the value of the text file to a database. How do I get the value of the fileupload textbox?  Here is my code so far:   Dim FILENAME As String = NEED VALUE OF FILEUPLOAD TEXTBOX VALUE HERE Dim myfile As String Dim objStreamReader As StreamReader objStreamReader = File.OpenText(myfile.Text) Dim contents As String = objStreamReader.ReadToEnd() t.Text = contents objStreamReader.Close() 

FileUpload path problem


I have not been able to uplaod a file to my web page although the code I am using works if I copy it locally. Perhaps I am missing something in the path or I need to change some security setting on the web page?

   protected void btnUpload_Click(object sender, EventArgs e)
        SelectedFileName.InnerHtml = txtFileField.PostedFile.FileName;
        FileType.InnerHtml = txtFileField.PostedFile.ContentType;

        // convert bytes to Kbytes
        int size = txtFileField.PostedFile.ContentLength / 1024;
        FileSize.InnerHtml = (size.ToString() + " KB");
        uploadDetails.Visible = true;

        string strFileName = txtFileField.PostedFile.FileName;
        string c = Path.GetFileName(strFileName);

            // not sure if this path is correct. not working anyway
            txtFileField.PostedFile.SaveAs("~/" + c); 
            feedBack.InnerHtml = "File uploaded successfully.";
        catch (Exception exp)
            string message = "File did not upload, please try again";
            feedBack.InnerHtml = message + "\n" + exp.Message.ToString();
            uploadDetails.Visible= false;
Thanks for any help.

FileUpload.SaveAs Problem


I'm uploading multiple PDF files from a CD to a folder on a server locally on the server itself. My problem is that the filenames and the PDF files is being uploaded, but the content of those PDF files themselves are missing. Their size is 0KB. 

FileUpload1.SaveAs(("C:\Documents and Settings\ABC\ABCD\ABCDE\PDF\" & Path.GetFileName((files(intCount1).ToString))
Not sure what i'm doing wrong here. I've tried a lot of other ways and I either get the path isn't found or or access is denied.
Thanks in advance for any help you guys can provide.




get full path from fileupload control in client side???


<script type="text/javascript" >

        function SetA()

                    document.form1.action = 'Default.aspx?fileName='+document.getElementById('FileUpload1').value;
    <form id="form1" runat="server">
        <asp:FileUpload ID="FileUpload1" runat="server"  />
        <asp:Button ID="btnupload" runat="server" Text="Upload" OnClientClick="SetA()" />



here in the  javascript function i need send full path of upload control?


please help in this situation? if anybody knows other way of sending full path please tell?


thank you,

Virtual Path Problem


 I get the following error on last line below (working on remote host): 'E:\web\sfcascom\ls_admin/uploads/images/001.JPG' is not a valid virtual path,

Note that the slashes go in different directions

I've tried a number of things but nothing seems to work. Thanks-


Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Drawing.Imaging
Imports System.Web.UI.WebControls

Imports System.Drawing.Imaging.ImageCodecInfo
Partial Class Protected_imageupload
    Inherits System.Web.UI.Page
    Private Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
        ' Initialize variables
        Dim sSavePath As String
        Dim sThumbExtension As String
        Dim intThumbWidth As Integer
        Dim intThumbHeight As Integer
        Dim sFilename As String = ""
        ' Set constant values
        'sSavePath = "images/"
        sSavePath = Server.MapPath("~/") + "ls_admin/uploads/images/"

        sThumbExtension = "_thumb"
        intThumbWidth = 160
        intThumbHeight = 120

        ' If file field isn?t empty
        If FilUpload.PostedFile IsNot Nothing Then
            ' Check file size (mustn?t be 0)
            Dim myFile As Http

Server side validation of Fileupload control not working



I've tried this method in my code behind to try and validate that the Fileupload control has a file or not. I get the error message the the event "Server Validate" cannot be found. Can anyone tell why? Thanks.

Public Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate

' Get file name

        Dim uploadAvatar As FileUpload = DirectCast(AdvertisementForm.FindControl("uploadAvatar"), FileUpload)

        Dim UploadFileName As String = uploadAvatar.PostedFile.FileName

        If UploadFileName = "" Then
            ' There is no file selected
            args.IsValid = False
            Dim Extension As String = UploadFileName.Substring(UploadFileName.L

Sys.require + wcf svc/jsdebug


using Sys.require i do this:


however if i need to call a wcf service aka Sys.scripts.WebServices namespace.

I need to include the svc file javascript proxy after this call:
    <script src="/Modules/ShoutBox/ShoutOutService.svc/jsdebug" type="text/javascript"></script>

placing this before sys.require gives me javascript errors that certain objects don't exist yet.. since sys.require dynamically downloads javacript libraries.

is there another approach I could use o wait till all
Sys.scripts.WebServices  namespace is down before retrieving my wcf proxy classes?

I would like to not rely on "inclusion" sequence .. hoping api already exists.

Creating a user friendly alias for the website path


 Hello mates,

I am hosting my ASP.NET application on a Windows 2003 Server.

To browse to my application one has to type the path :http://serverName/applicationName

I want users to only type  applicationName on the web adress area.I believe there is something to do with alias and CNAME on DNS records that can adress this.

Any help on how to go about doing this will be highly appreciated.

connection to SQL Server files (*.mdf) require SQL server express 2005 to function properly.


I dont have the SQL EXPRESS installed instead I have SQL Standard Edition.

 I have two SQL Server instances installed.

 1- UserLT (this is sql 2000)
2- UserLT\SQL2005 (this is SQL 2005 named instance)

But when i try to add a database to my VS website project I get the following error:

Connection to SQL Server files (*.mdf) require SQL server express 2005 to function properly. please verify the installation of the component or download from the URL: go.microsoft.com/fwlink/?linkId=4925

I went in Tools>Opetions>DataBase tools>Data Connection>Sql Server Instance Name (blank for default)

and changed the "SQLEXPRESS" to "USERLT\SQL2005".

But I still get the same error message. Any ideas how i can resolve this issue?

require Video tutorial for Composite server control and rendered server control


hi guys

i am new to forum and technology so please go easy

according to what i read from web there 3 types of custom server controls

1. composite



i found video tutorial to create and use superclass custom control in your project (extending dropdown control functionality)

i am trying to search video tutorial for other 2 types .please help me.

How to set SearchRoot Path in Active Directory in this scenario


How to set SearchRoot Path in Active Directory in this scenario:

Functionality: We have scenario that 1<sup>st</sup> hit one LDAP server with some 'fixed user name' &' fixed password ' and filter data with specific User name(which given by user) getting 'User dn'.

After that we hit Next LDAP server based on the 'User dn' getting from 1<sup>st</sup> server.

(So, in my case 1<sup>st</sup> LDAP server works like as Load balancing server but functionalitywise it is different)


Split URL/Path in Classic AND .net 2.0


I need to be able to get the different parts of the URI (and convert from/to relative page paths) in BOTH classic ASP and .Net 2.0 (VB).

For example, if I have "http://sitename.company.com/index.aspx?sec=fred&pag=dis&mode=1" OR "/index.aspx?sec=fred&pag=dis&mode=1"

IS there a function where I can pass in either string (assuming I'm on sitename.company.com) and get back an array with:

(0): sitename.company.com
(1): index.aspx
(2): sec=fred&pag=dis&mode=1

(Or, alternately, three different functions that would return the three parts?)


Path not valid.



im trying to save a file, filename as current date and time.it will give an error.

any ideas.

here is my code

string datetime=DateTime.Now.ToString();

if (GridviewtoCSV("~/Admin/doc/Reports/" + batchid.ToString() + datetime + ".csv", transactiongrid) && GridviewtoPDF("~/Admin/doc/Reports/" + batchid.ToString() + datetime + ".pdf", transactiongrid))

Scale Out: Distributed Caching On The Path To Scalability


Developers frequently face issues related to scalability bottlenecks when they have applications that need to handle a lot of load. This article describes the role of a distributed cache in building scalable applications.

Iqbal Khan

MSDN Magazine July 2009

Foundations: Render Text On A Path With WPF


With Windows Presentation Foundation (WPF) you can lay out text on a path, then animate the individual points defining the path and watch the characters bounce around in response.

Charles Petzold

MSDN Magazine December 2008

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend