Search results for 'BlackJack'. 1 post(s) found.
- 2008/03/12 How to rename(change file name) in C# ? (1)
Simplest way to change file name in C# is using File.Move() function.
Here's the simple example change file name for Samsung Black Jack Phone. However it may work on another platform if it supports .NET compact framework.
In addition, File creation time can be obtained by FileInfo class. See the below example for addition example.
//
// Programmed 2008 by Kurapa Chunun Kang (kurapa@kurapa.com)
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO; // added for FileInfo class
namespace fnc
{
class Program
{
// developed for Samsung Black Jack Smart Phone
static void KChangeFileNameForBlackJack(string strDir)
{
int iocnt = 100;
DirectoryInfo dir = new DirectoryInfo( strDir);
FileInfo[] bmpfiles = dir.GetFiles("PIC-*.jpg");
Console.WriteLine("Total number of bmp files", bmpfiles.Length);
foreach (FileInfo f in bmpfiles)
{
String fn = f.CreationTime.Year + "-"
+ ((f.CreationTime.Month<10) ? "0":"") + f.CreationTime.Month + "-"
+ ((f.CreationTime.Day < 10) ? "0" : "") + f.CreationTime.Day + "_"
+ ((f.CreationTime.Hour < 10) ? "0" : "") + f.CreationTime.Hour
+ ((f.CreationTime.Minute < 10) ? "0" : "") + f.CreationTime.Minute
+ ((f.CreationTime.Second < 10) ? "0" : "") + f.CreationTime.Second
+ (iocnt++)
+ ".jpg";
File.Move( strDir + "\\" + f.Name, strDir + "\\" + fn);
}
}
static void Main(string[] args)
{
KChangeFileNameForBlackJack(@"\Storage Card\My Pictures");
}
}
}
// Programmed 2008 by Kurapa Chunun Kang (kurapa@kurapa.com)
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO; // added for FileInfo class
namespace fnc
{
class Program
{
// developed for Samsung Black Jack Smart Phone
static void KChangeFileNameForBlackJack(string strDir)
{
int iocnt = 100;
DirectoryInfo dir = new DirectoryInfo( strDir);
FileInfo[] bmpfiles = dir.GetFiles("PIC-*.jpg");
Console.WriteLine("Total number of bmp files", bmpfiles.Length);
foreach (FileInfo f in bmpfiles)
{
String fn = f.CreationTime.Year + "-"
+ ((f.CreationTime.Month<10) ? "0":"") + f.CreationTime.Month + "-"
+ ((f.CreationTime.Day < 10) ? "0" : "") + f.CreationTime.Day + "_"
+ ((f.CreationTime.Hour < 10) ? "0" : "") + f.CreationTime.Hour
+ ((f.CreationTime.Minute < 10) ? "0" : "") + f.CreationTime.Minute
+ ((f.CreationTime.Second < 10) ? "0" : "") + f.CreationTime.Second
+ (iocnt++)
+ ".jpg";
File.Move( strDir + "\\" + f.Name, strDir + "\\" + fn);
}
}
static void Main(string[] args)
{
KChangeFileNameForBlackJack(@"\Storage Card\My Pictures");
}
}
}
Another posts included in "C#"
| Retrieve system information (0) | 2008/09/22 |
| Convert System.DateTime to UNIX timestamp (0) | 2008/09/22 |
| Finding process name on OS (0) | 2008/09/22 |
| Find Files in certain directory (0) | 2008/02/25 |
| How to speed up access to the RichTextBox Lines property (0) | 2007/09/25 |
| How to detect resource leaks in a Form (0) | 2007/09/25 |
| The best way to enable and disable buttons, menu items and toolbar buttons (0) | 2007/09/25 |
| How to exit from a console application (0) | 2007/09/25 |

fnc.zip
Prev

Rss Feed