.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

Illegal characters in path

Posted By:      Posted Date: August 29, 2010    Points: 0   Category :ASP.Net
I have a web site developed in ASP.NET 2.0 and VB.Net.It works perfectly on my PC when I launch it from visual studio but when i copy it on server it shows an error: Illegal characters in path. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: Illegal characters in path.Where is the problem??

View Complete Post

More Related Resource Links

Handling ArgumentException: Illegal characters in path

How can I handle URLs with illegal characters such that they don't throw an unhandled exception? I tried an HttpModule but that doesn't catch the error. I'm using IIS6 and .Net 2.0.

System.ArgumentException: Illegal characters in path



I am trying to download a file from a location and save it in another location using webclient.downloadfile:

This line is erroring out:

myWebClient.DownloadFile(RemoteUri & Files(i), Application.StartupPath & "\" & Files(i))

This is the value in RemoteUri & Files(i):

This is the value in Application.StartupPath & "\" & Files(i):

C:\Program Files (x86)\Microsoft\TestWiform\Testwiform.msi

Error:System.Net.WebException: An exception occurred during a web client request----->System.ArgumentException: Illegal characters in path

What is the illegal character here?

Thanks in Advance


SQL Server 2008 enterprise upgrade failed: Illegal characters in path.


My production upgrade from SQL Server 2005 to 2008 just went down. This is a single x64 server installation the log reported the strange set of problems:


2011-04-13 10:14:48 AS: Result: (Utility) Success
2011-04-13 10:14:48 AS: Action: Set Admin Rights For Folder(F:\SSAS\AS_TEMP\|)
2011-04-13 10:14:48 Slp: Sco: Attempting to set directory full path
2011-04-13 10:14:48 Slp: Sco: Attempting to normalize directory path F:\SSAS\AS_TEMP\|
2011-04-13 10:14:48 Slp: Prompting user if they want to retry this action due to the following failure:
2011-04-13 10:14:48 Slp: ----------------------------------------
2011-04-13 10:14:48 Slp: The following is an exception stack listing the exceptions in outermost to innermost order
2011-04-13 10:14:48 Slp: Inner exceptions are being indented
2011-04-13 10:14:48 Slp: 
2011-04-13 10:14:48 Slp: Exception type: Microsoft.SqlServer.Configuration.Sco.ScoException
2011-04-13 10:14:48 Slp:   Message: 
2011-04-13 10:14:48 Slp:     Illegal characters in path.
2011-04-13 10:14:48 Slp:   Data: 
2011-04-13 10:14:48 Slp:    DisableRetry = true
2011-04-13 10:14:48 Slp:   Inner exc

Deployment Failure - System.ArgumentException: Illegal characters in path.


I have created an asp.net MVC3 website I would like to upload via Webmatrix. The website uses a database I set up in webmatrix (SQL Compact Databases). I am using an ado.net data entity model to interface with the database. The website runs properly on my local machine, but when I attempt to deploy it via webmatrix I recieve the following error:

System.ArgumentException: Illegal characters in path.
   at System.IO.Path.CheckInvalidPathChars(String path)
   at System.IO.Path.IsPathRooted(String path)
   at Microsoft.WebMatrix.Deployment.DeployFilesFilter.ApplyFilterForSqlCeInternal()
   at Microsoft.WebMatrix.Deployment.DeployFilesFilter.ApplyFilterForSqlCe()
   at Microsoft.WebMatrix.Deployment.DeployFilesFilter.ApplyFilters()
   at Microsoft.WebMatrix.Deployment.MsDeployWorker.Execute(Boolean pullback)

 After a little experimentation I have determined that ths problem appears to be linked to my web.config connection string for the databases (With this string removed the deploy error no longer occurs).

<add name="MyDatabaseEntities" connectionString="metadata=res://*/Models.MyDatabaseModel.csdl|res://*/Models.MyDatabaseModel.ssdl|res://*/Models.MyDatabaseModel.msl;provider=System.Dat

Problem Cleaning Illegal Characters out of an XML String



I'm trying to strip illegal characters out of an XML string before I send it off to a public web service.  The xml will look something like this:

<field name="first_name">George</field>
<field name="last_name">Harrison</field>
<field name="notes">This is a note.  Any character could appear here</field>

I need to pull out any ampercand (&) charachters in the any of the fields, as well as any < or > characters, which would make the XML unreadable.

I've tried it like this:

Private Shared Function cleanQuery(ByVal queryNode As String) As String 
    Dim root As XElement = XElement.Parse(queryNode) 
    For Each x As XElement In root.Elements 
        x.Value = x.Value.Replace("&", "&").Replace("<", "<").Replace(">", ">") 
    Return root.ToString() 
End Function


That doesn't work so well.  I get the error stating:

     There are multiple root elements. Line 1, position 15.

I tried wrapping the XML in a single root element, like this:

Private Shared Function cleanQuery2(ByVal q

260 Characters in File Path - Too long


I have a Windows Service that is getting cought up on file paths that are longer than 260 characters.  I have googled just about every combination of this problem I can think of as well as various other forums.  From what I have read, Windows System.IO has a limitation on file paths of 260 characters or less.  However Microsoft's latest release of Robocopy has support for 260+ characters.  I have also read that a couple people mentioned unicode file paths which support up to 32,000.  The limitation is set with the MAX_PATH and internet explorer and Robocopy use unicode filepaths to save long files.

My workaround right now is to trap and skip the folders while I would like in the future to be able to have paths longer than 260 characters.  This right now is the ONLY work around, so the obvious "why dont you just move the folders?" response is out of the question.

My question is: Is there a way to use unicode file paths with the FileInfo class?  Perhaps using PInvoke?  Can you give an example for me?

Event Type: Error
Event Source: File Mirroring Service
Event Category: None
Event ID: 0
Date:  8/9/2005
Time:  8:42:28 AM
User:  N/A
An error occured:
The path is too long after being

Sharepoint/SSRS: The full path must be less than 260 characters long

Question: I setup a dual server Sharepoint deployment with SSRS and now I keep getting the error like the one below when I try to save a report or a datasource on the server:

The path of the item 'http://intranet/sharepoint/CompanyReports/MyReports' is not valid. The full path must be less than 260 characters long; other restrictions apply. If the report server is in native mode, the path must start with slash.

I'm looking into permissions but this happens regardless of authentication I select on the client end.

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

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.

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)


IE 8 Issues with Chinese/Japanese Characters


On my web application, I display information in different languages. Everything works fine in IE compatibility mode and FireFox but it shows boxes for chinese/japanese languages. I am pretty much having the same issue as described here



Thanks for your help.

Store and display Japanese characters



Can anyone tell me the best way of storing Japanese characters through ASP.NET.
I have to put characters into a asp:textbox on one page, which saves it to an Access DB.
On a second page I want to display the content in a asp:label.

Should I store the characters directly to the database or should they be encoded, and
how do I encode the characters? 

In my web.config i have:

<globalization fileEncoding="ISO-2022-JP" requestEncoding="ISO-2022-JP" responseEncoding="ISO-2022-JP" culture="ja-JP" uiCulture="ja-JP" />  

On the display page I have:

<meta HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=shift_jis">


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?)


string.Split - not all characters allowed as separator



I am working on a site where I use the Split function on a string.

To make sure I used a separator character that I do not use anywhere in the data I selected the character '£'.

This worked fine in Firefox and Safari, but in IE8 I get an 'Index out of range' error, so apparently the '£' character is not handled correctly.

I changed the separator to ';', and then it works fine.



Remove characters in a string


i have a string like this   sravani/, asdfff/, lsdsf/
i want to remove last character '/'  in the above string...
which function can i use?

pls help me....

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

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