We help IT Professionals succeed at work.

Problem Renaming Directories in ASP.Net (VB)

Iguanasan
Iguanasan asked
on
1,151 Views
Last Modified: 2012-08-14
Here's the original question:

https://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_20869659.html

A solution that works gets you the 500 from that question and another 500 from this one.  I need the answer!  It's driving me crazy!
Comment
Watch Question

This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Iguanasan,
I tested it here. Your code works perfect IF "D:\Work\Projects\devsite\web\documents\excel" has the option set to inherits parent permissions.


Esteban Felipe
www.estebanf.com

Author

Commented:
I just went in and "Replaced Permissions on all Child Objects".  Still a no-go.  Group "Everyone" has Full permissions on documents and all subfolders.  Now, you know my frustration.  Could it be a bug in my version of .Net?  What version are you running on which OS?

I'm running: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
on Windows XP with all up to date security patches as far as I know.

Regards, Iguanasan
I'm running same version here.

Maybe the error is more related to the part that says "An attempt was made to move a directory to a different volume". Let me do some test and research. I'll get back to you
Well, I tried to move a directory to other volumne and I got this exception

Source and destination path must have identical roots. Move will not work across volumes.
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.IO.IOException: Source and destination path must have identical roots. Move will not work across volumes.

But that's not your exception. :(

Do you have any weird setting in your filesystem (raids, dinamic volumes, mount points, etc...)?
please try this test and tell me the results:
1.- Go to the security tab of D:\Work\Projects\devsite\web\documents\
2.- Click advanced
3.- In the new window go to the "effective permissions"
4.- Click select
5.- Write aspnet
6.- Click ok
7.- Check the results

Author

Commented:
NO.  I have a single physical drive partitioned into a C:/ Drive and a D:/ drive.  I tried moving the code to c:/inetpub/wwwroot/ as per someone else's suggestions, same error.

Following your suggestion I double-checked permissions.  There is a checkmark next to each and every item in the list.  ASPNet account has full permissions.

It must be something really silly, I just don't know what it is!

Iguanasan
Ok, let start with the oldest and best error resolution technique: Discarding :).

first, let's be sure it's not a permission problem. can you do this from your web app, please?:

System.IO.DirectoryInfo dirInfo = System.IO.Directory.CreateDirectory("D:\Work\Projects\devsite\web\documents\IHATEBUGS")

Let me know what happended.

Author

Commented:
Error:

Compiler Error Message: BC30691: 'DirectoryInfo' is a type in 'IO' and cannot be used as an expression.

Source Error:

Line 2:  <script language="vb" runat="Server">
Line 3:  Sub Page_Load(Sender as Object, E as EventArgs)
Line 4:        System.IO.DirectoryInfo dirInfo = System.IO.Directory.CreateDirectory("D:\Work\Projects\devsite\web\documents\IHATEBUGS")
Sorry, my bad... I'm too used to C#. The correct sintax is
Dim dirInfo As System.IO.DirectoryInfo= System.IO.Directory.CreateDirectory("D:\Work\Projects\devsite\web\documents\IHATEBUGS")

Author

Commented:
Sorry.  I should have seen it too.  My ASP.Net isn't very good yet, but I should have recognized that it was not valid VB.

Anyway, it seems consistent:

Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path "D:\".

Source Error:


Line 2:  <script language="vb" runat="Server">
Line 3:  Sub Page_Load(Sender as Object, E as EventArgs)
>>>Line 4:        Dim dirInfo As System.IO.DirectoryInfo= System.IO.Directory.CreateDirectory("D:\Work\Projects\devsite\web\documents\IHATEBUGS")
Line 5:        'System.IO.File.Move("D:\Work\Projects\DevSite\web\documents\WordPerfect\file1.txt","D:\Work\Projects\DevSite\web\documents\WordPerfect\file2.txt")
Line 6:        Try
 

And I get the same error if I drop the \IHATEBUGS

Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path "D:\".

Source Error:


Line 2:  <script language="vb" runat="Server">
Line 3:  Sub Page_Load(Sender as Object, E as EventArgs)
>>>Line 4:        Dim dirInfo As System.IO.DirectoryInfo= System.IO.Directory.CreateDirectory("D:\Work\Projects\devsite\web\documents")
Line 5:        'System.IO.File.Move("D:\Work\Projects\DevSite\web\documents\WordPerfect\file1.txt","D:\Work\Projects\DevSite\web\documents\WordPerfect\file2.txt")
Line 6:        Try
 
and D:\Work\Projects\devsite\web\documents\ exists, right?
Top Expert 2004

Commented:
wow, but changing the user to SYSTEM sounds as a really bad idea from a security perspective
Top Expert 2004

Commented:
:) yes, it could be - it just a solution, and it can be a better solution if the programmer write his code correct - it is actually a permission issue - but obviously the other suggestions are not correct.

B..G

Author

Commented:
esteban: Yes, d:\work\projects\devsite\web\documents exists.

mmarinov: I am *not* going to elevate the aspnet user to SYSTEM, that is just plain rediculous.  There has to be another solution.  You say "...if the programmer write his code correct - it is actually a permission issue".  What is wrong with my code?  That's why I am asking for help.  The code I wrote is virtually a copy of what's in the help files for renaming directories.  esteban says it works on his machine but it doesn't work on mine or my production server.

If I am doing something wrong, correct me.

Regards, Iguanasan
Top Expert 2004

Commented:
"...if the programmer write his code correct " was for the SYSTEM user and about the comment from esteban
the code works on the esteban's machine becaus he has grant access to the aspnet user itself not to everyone
i'm not telling you that your code is incorrect - but you have to listen to esteban to set the aspnet user with full permission to you directory and its subdirectories

B..G

Author

Commented:
Son of a b**ch!!!!  Got it.  Apparently, we're supposed to take the error message quite literally.  The error message (when not catching it with the Try Catch stuff is: "Could not find a part of the path"

So, in my case, I'm trying to rename d:\work\projects\devsite\web\documents\WordPerfect so ASPNet user has to have at least READ access do D:\, d:\work\, d:\work\projects\, d:\work\projects\devsite\, d:\work\projects\devsite\web\ and READ/WRITE to the rest!

Seems like a security flaw to me.  I'll live with it as it's not a horrible thing.  I can set Deny Read on non-web folders.  It's a pain in the *ss though.

Thanks for the help.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.