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

Post New Web Links

Path Too Long Problem. Accessing filenames longer than 260 chars using unicode and kernel32.dll.

Posted By:      Posted Date: October 23, 2010    Points: 0   Category :.NET Framework
I found this article a few weeks ago that provided a way to access files and folders past the 260 char length:


I put the code from "Finding Files and Folders" in a dll and wrote an app in vb accessing these functions.  However, the code randomly breaks on a specific kernel32 function call. 

I noticed that if the search finds a file (not folder) longer than 12 to 14 characters then it breaks on occasion.  This is strange because I would think it would either never break or always break.

Here's the line where it breaks:

// find next

found = FindNextFile(findHandle, out findData);

Any ideas?


View Complete Post

More Related Resource Links

Problem to use unicode chars in yahoo mail

Hi i have a problem to send email via smtpClient class to yahoo mail. if i send a unicode email from non-Yahoo account to yahoo mail, it works correctly (display unicode chars correctly without any making change), but when i send from yahoo account to yahoo mail, it does not display characters correctly and i should change it's encoding to UTF8. can anybody help me to work-around this problem ? Please see my previous thread in this link. thanks in advancehttp://www.codeproject.com/KB/codegen/DatabaseHelper.aspx

a problem in work with unicode chars in WHERE clause



I'm designing a website for Persian language

I create a stored procedure that contain :

SELECT @sqlstring = ' SELECT TOP ' + CONVERT(nvarchar,@RowCountUser) + ' Stars FROM SpecialAds WHERE REPLACE(REPLACE(MainGroup,NCHAR(1610),NCHAR(1740)),NCHAR(1603),NCHAR(1705)) = ''REPLACE(REPLACE(' + @MainGroup + ',NCHAR(1610),NCHAR(1740)),NCHAR(1603),NCHAR(1705))'' AND Status = ''verified'' ORDER BY Stars Desc';

EXEC (@sqlstring)

no record is not returned and printed :

Invalid column name : ...

but when I change code above to :

SELECT TOP 5 Stars FROM SpecialA

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

Problem in accessing resource file dynamically.


Steps I have followed are
1.I have created myres.en-GB.resx file at C:.
2.then created locale specific myres.en-GB.resources using resgen at c: only,
resgen c:\myres.en-GB.resx
3.Linked the Resource File to Assembly using AL.exe which is giving me assembly at c: only.
Al /t:lib /embed:myres.en-GB.resources /out:ClassLibrary1.dll
4.I have created one web application using vs 2008 & then build it.
5.Then placed both resource file & dll in web applications Bin\en-GB folder.
6.Anf finally written code at page load like
 CultureInfo info = new CultureInfo("en-GB");
            Thread.CurrentThread.CurrentCulture = info;
            Assembly asd = Assembly.Load("ClassLibrary1");
            ResourceManager res = new ResourceManager("myres.en-GB", asd.GetSatelliteAssembly(info));
            string sdf = res.GetString("Lab1");

but after running application I m getting following error
MissingManifestResourceException", "Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Cla

Problem accessing Sharepoint 2007 MySite


My users are having an issue accessing their mysites.  When they go to the main portal page or any other site and click the link at the top right of the page to go to their Mysite they are thrown into an endless authentication loop.  If they cancel out of the loop the URL in the address bar is for http://mossserver/_layouts/MySites.aspx

For a user to successfully get to their myself they need to enter the full url like http://mossserver/personal/username/default.aspx

Now, I know somewhat how this happened.  It resulted from me trying to delete a user's mysite and I apparently did it wrong but I'm not sure what I did.  It almost seems like I deleted a redirect page or something...

Looking for any ideas.



Problem in accessing datakeys

I have kept an int element and char element as datakeys of gridview,first one being the int element. But when I write the following code, error comes up stating that "Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index" Why does the error come up? and how to remove it? protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { Char s =Convert.ToChar(GridView1.DataKeys[e.Row.RowIndex][1]); if (s == '0') e.Row.BackColor = System.Drawing.Color.Red; else e.Row.BackColor = System.Drawing.Color.SeaGreen; }  

Path too long packaging or deploying SP2010 solutions in VS2010

I'm regularly getting "Error 2 The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters" building projects with VS2010 for SP2010. I've done what I can to reduce the length of the path but unfortunately I have rules for the namespaces I must use. This is really frustrating and causing issues for our team trying to meet our business requirements. Is there any way to improve this situation apart from shortening the paths? (Similar to this post for the RC build: http://social.technet.microsoft.com/forums/en-us/sharepoint2010programming/thread/36D35235-6736-410F-ACC6-03C0BDCC4FE2) Thanks, Alex.Alex Angas - http://www.alexangas.com/blog

SSIS 2005 - Send Mail Task - signature appended to email is garbled - unicode problem?

Hi, I'm pretty new to SSIS so go easy on me. I have a Send Mail Task to notify if a file cannot be imported - the mailbody is created on the previous step by a VB.NET script task to include the name of the file and the path it's been archived to. The problem I'm having is that while the body of the email I've created is displaying fine, our company's Exchange server appends a signature to all emails, and this is coming up as undisplayable characters, presumably due to some kind of unicode encoding problem. I've tried casting the email body in an expression to DT_STR (doesn't work as DT_STR "cannot be converted to a supported type" which seems a bit odd but never mind), DT_WSTR (garbled signature), DT_TEXT/DT_NTEXT (strange error on this one - "Attempted to read or write protected memory") none of those ideas worked, and I'm a bit stumped now. Can anyone help? I'm using SSIS 2005 with SP3

Having problem accessing multi-choice parameter in SQL Query in Report.

Hi, I have a report with a multi-choice input parameter. My report contains a dataset that uses CHARINDEX on this multichoice parameter. The dataset query is in text, not in stored procedure. When I run the report I get "the charindex requires 2-3 arguments the reason being that the SQL is run as follows (You can see the multi-choice list screws up the string: exec sp_executesql N'Select test.Region [Region], test.Location [Location], nvarchar3 [Year], nvarchar4 [StatisticType], nvarchar5 [StatisticType2], ntext2 [Detail], float1 [Amount]   from [WSS_Content].[dbo].[AllUserData] UD   inner join [WSS_Content].[dbo].[AllLists] AL on AL.tp_ID = UD.tp_ListId and AL.tp_Title=''Statistics''   left outer join   (       Select UD.tp_id [ID],nvarchar1 [Region],     nvarchar3 [Location]   from [WSS_Content].[dbo].[AllUserData] UD   inner join [WSS_Content].[dbo].[AllLists] AL on AL.tp_ID = UD.tp_ListID and AL.tp_Title=''Regions''   where UD.tp_ListId = AL.tp_ID   and UD.tp_ListId = AL.tp_ID   and UD.tp_DeleteTransactionId = 0x0   and tp_IsCurrentVersion = 1   ) test on test.id = UD.int1   where UD.tp_ListId = AL.tp_ID   and UD.tp_ListId = AL.tp_ID   and UD.tp_DeleteTransactionId = 0x0   and tp_IsCurrentVersion = 1  &n

Path too long (Exception from HRESULT: 0x80010135)

Hi I have recieve this error any idea how to solve it Path too long (Exception from HRESULT: 0x80010135) ThanksMomo

Accessing path information

Hi,I'm developing an application where the user needs to browse to a particular folder( network folder) and then I need to pass the name out to a text box.For example if the user browsers to a folder "//Myfirst/test/ABC/ " then I need to retrieve the last directory name which is "ABC". So textbox1.text = ABC .Currently using a file uploader to browse to the directory but I find that the path information cannot be retrieved throught a file uploader as the browser security does not allow this information to be passed out. Would appreciate any help/suggestions in getting this information needed to the text box. Thanking in advancePS: The folder which the user browsers to ( in the above  "//Myfirst/test/ABC/ ") is a blank folder and does not have any files in it.

The Path problem?

I hope to get the following result, how can I write code? Thanks!                 Source                                                                                      Target1. http://localhost:1131/Mysite/Member/MyProject.aspx     =>       /Member/MyProject.aspx2. http://localhost:1131/Mysite/MyProject.aspx                   =>       /MyProject.aspx3. http://localhost:1131/Mysite/MyProject.aspx?Type=2     =>       /MyProject.aspx?Type=2 4. http://www.Mysite.com/Member/MyProject.aspx             =>       /Member/MyProject.aspx5. http://www.Mysite.com/MyProject.aspx   &nb

Accessing SharePoint via UNC Path Causes Password Prompt

I have a script that has to use a UNC path to drop a file into a SharePoint document library. For some users on some computers when they try to access the SharePoint site (http://Sharepoint) via the UNC Path (\\Sharepoint) they get a password prompt. Most users do not get a password prompt and get let right in. I have checked all the obvious things like zone settings, saved network passwords, etc. If I log a user that gets a password prompt into a different machine (that isn't having the problem) then it works just fine. This indicates to me that it is a client issue as opposed to a user issue.

Problem in Path translation

Hi,I am developing a very basic application in C# and Asp.Net using New Website-->Asp.Net web site.This is a simple login control application available in Visual Studio.  After starting a project, I found folder structure like that Project name "WebSite2" under which I have  folders like "Account", "Scripts" and "Styles" and few files like "About.aspx", "Default.aspx" and "Web.config" under the same "WebSite2" folder. Under "Account" folder I have files like "ChangePassword.aspx","ChangePasswordSuccess.aspx","Login.aspx","Register.aspx" and "Web.config". Now I have add a simple page "ThankYou.aspx" under "Account" folder and "Thanks" under "WebSite2" folder. I have modified "Register.aspx.cs" file so that whenever a new user will register, an email will be sent to the persons inbox and from where he will activate his account and this functionality is working fine. Now the problem is that whenever a new user registered, an email will be send to him and simultaneously he will be landed to "ThankYou.aspx" page, but here the user is redirecting to "Login.aspx" page. i have tried it with so many combinations but always getting "Login.

Problem Accessing Mysites




I accedentialy deleted a handfull of users profiles. All of the users had created mysites. I just let FIM sync everything up and thought I would be alright, since I never deleted their AD account. When the users with recreated Profiles try to access their mysite they get the following error

Your personal site cannot be created because a site already exists with your username. Contact your site administrator for more information.

If I try to access any of the sites from the user profile service and click "manage personal site" it says the site has not been created.


The site is there users can successfuly access their personal and shared documents from the following links


http://xxx.xxx.com/persoanl/username/shared documents

but when trying to access

http://xxx.xxx.com/persoanl/username it gets redirected to the settings.aspx page on the mysite host site

Its as if the newley created profiles are missing a link to the already create mysites. I can successfuly get to _layoute/settings.aspx on the sites and have verified the permissions and actually reset them. Still no luck.


any ideas ?


file path problem


in the application, I need write a jpg file to local folder on server, then show it in browser.

so, the code likes show this file:

HttpContext.Current.Request.Url.Host + "/View/ViewJpg.aspx"

In the ViewJpg.aspx, it will process the jpg. /view is in root folder.

it works fine when the code is on a server, however, I have problem when I debug in on local machine.

because the code is actually http://localhost/mYproject but HttpContext.Current.Request.Url.Host only returns http://localhost.

what's the best way to deal with this?


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.

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