Remove the '.' symbol from the file name for Summer Study Notes (4)

Source: Internet
Author: User

Today I found a small problem with the mp3 converter (mp3 converter v2.0). I 've got a lot of vod on emule and want to use mp3 to listen to it, after the conversion, I found that the file name is very short (everything on the emule is a super-long name), and I am surprised that the programmer must be very lazy and use the first one directly '. 'The name before the symbol is helpless, so I had to compile a small program and modify it in batches.

Code
Using System;
Using System. Collections. Generic;
Using System. Text;
Using System. IO;

Namespace DeleteDot
{
Class Program
{
Static void Main (string [] args)
{
String [] files = Directory. GetFiles (@ "G: \ Europe and America mtv ");
String fname = null;
Foreach (string fn in files)
{
FileInfo f = new FileInfo (fn );
Int dotSum = 0;
For (int I = 0; I <fn. Length; I ++)
{
If (fn [I] = '.')
{
DotSum ++;
}
}
Int dotDel = dotSum;
Fname = fn;
For (int I = 0; dotDel> 0; I ++)
{
If (fname [I] = '.')
{
If (dotDel! = 1)
{
Fname = fname. Remove (I, 1 );
I --;
}
DotDel --;
}
}
File. Move (fn, fname );
}
Foreach (string str in Directory. GetFiles (@ "G: \ Europe and America mtv "))
{
Console. WriteLine (str );
}

Console. ReadLine ();
}
}
}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.