473,396 Members | 1,849 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Rename Folder

An inquisitive question......

A ListBox lists all the directories & files residing in a directory on
the server. Assume that the ListBox lists 2 directories & 4 files. Also
assume that one of the directories is named 'mydir' (without the
quotes). Note that the all the letters in the directory name are in
lowercase.

To rename any directory/file, one can use the Move method of the
Directory/File class respectively but ASP.NET doesn't allow to JUST
change the case of a directory/file name. For e.g. if I want to change
the name of the directory from 'mydir' to 'MYDIR', ASP.NET generates
the following error:

Source and destination path must be different.

when the Move method of the Directory class is invoked. This, I
believe, is obvious because the Move method is primarily meant for
moving a directory/file from one location to another location.

Hasn't Microsoft included any method in the ASP.NET Framework to
exclusively rename a directory/file. Isn't there any way by which I can
change the directory name from 'mydir' to 'MYDIR'?

Though strictly speaking, changing the directory name from 'mydir' to
'MYDIR' doesn't amount to renaming; it's merely changing the case of
the directory name.

Note that if you navigate to 'mydir' from 'My Computer', then Windows
does allow users to change the directory name from 'mydir' to 'MYDIR'
i.e. Windows allows users to just change the case of a directory/file
name without generating any error.

Jan 10 '07 #1
3 3583
This is because the Windows file system is not case-sensitive. What you have
to do is to create a temporary folder, move the contents of the "mydir"
folder to the temporary folder, delete the "mydir" folder, create a new
folder named "MYDIR," move the contents of the temp folder to the "MYDIR"
folder, and delete the temp folder.
couldn't you rename the temp folder to "MYDIR", after removing the
original "mydir"? Saves maybe a lot of copying.

Or now that I think about it some more, what about renaming "mydir" to
some different name ("mydir-temp") and then renaming that to "MYDIR"?
Both would be "real" renames to a case-insensitive filesystem.

Hans Kesting
Jan 10 '07 #2
"Hans Kesting" <ne***********@spamgourmet.comwrote in message
news:mn***********************@spamgourmet.com...
Or now that I think about it some more, what about renaming "mydir" to
some different name ("mydir-temp") and then renaming that to "MYDIR"?
That's certainly the way I do it...
Jan 10 '07 #3
Yes, now that I think about it. Much better.

--

Kevin Spencer
Microsoft MVP
Bit Player
http://unclechutney.blogspot.com

Where there's a Will, there's a William.

"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:Oz**************@TK2MSFTNGP02.phx.gbl...
"Hans Kesting" <ne***********@spamgourmet.comwrote in message
news:mn***********************@spamgourmet.com...
>Or now that I think about it some more, what about renaming "mydir" to
some different name ("mydir-temp") and then renaming that to "MYDIR"?

That's certainly the way I do it...

Jan 10 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: dudufigueiredo | last post by:
I have one folder containing mp3 files, the folder is: C:\My Shared Folder\Rubber Soul And the files are: 01 drive my car.mp3 02 norwegian wood.mp3 03 you won't see me.mp3 04 nowhere man.mp3...
1
by: Jay at SCA | last post by:
I've been having the following issue with a windows service I've created in vb.net (.net fw 1.1): Basically, my service monitors a folder for the creation of any new files of a particular type...
3
by: Erik Foreman | last post by:
I am using a folderbrowserdialog object to prowse to a folder then once in that folder I am going to have my program rename all of the files in that folder. I know the rename funchtion but I am not...
9
by: _DD | last post by:
Is there any easy way to rename an entire project? I'd like to change everything: folder, sln file, etc.
3
by: OdAwG | last post by:
Hello All, I would i check to see if a file exist and if it does exist, then rename the file with the date and time attached to the name: Example: If...
6
by: shuaishuaiyes | last post by:
Hello everyone... I'm a Chinese student and my English is very poor...So excuse me if I make grammar mistake. I want to ask some questions about "rename". I'm a beginner, so my C ..... :) I...
0
by: aris1234 | last post by:
how to rename file name in DB..??? this my code, but this code only save image to folder, can't rename file in DB : <?php //Сheck that we have a file $folder = "../property/$spid";...
1
by: keerthisreenu | last post by:
hai to all..!!! i am facing a problem with mov(....) in c#. i want to rename a folder with the code. iam using mov command. its working. but if i want to rename the folder to capital letters,...
2
by: tanichka | last post by:
Hello you helpful folk! Please look at my script and tell me what I am doing wrong! I am cleaning the names of my music files from unnecessary symbols, and the cleaning works fine, however the perl...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.