빠른 질문입니다. 파일 디렉토리를 반복하고 Julian이 아닌 dateformat으로 이름을 바꾸려고합니다. 모든 파일은 DailyFile.YYYYddd입니다. DailyFile.mm-dd-yyyy로 변경하고 싶습니다. 줄리안 날짜 변환을 연습 할 수없는 것 같습니다. 누구든지 도움을 줄 수 있습니까? 감사합니다!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Globalization;
namespace TestingFileRename
{
class Program
{
static void Main(string[] args)
{
string[] dirs = Directory.GetFiles(@"C:\TestDirectory\", "MERSDLY.*");
JulianCalendar juliCal = new JulianCalendar();
foreach (string file in dirs)
{
// Convert Julian date to MM-DD-yyyy format here and replace the filetail with it.
//file.move(file,filefront + new date string);
}
}
}
}
static void Main(string[] args)
{
var dirs = Directory.GetFiles(@"C:\TestDirectory\", "MERSDLY.*");
foreach (string file in dirs)
{
var parts = file.Split(".");
var year = new DateTime(int.Parse(parts[1].Substring(0,4)), 1, 1);
year = year.AddDays(int.Parse(parts[1].Substring(4)) - 1);
parts[1] = year.ToString("MM-dd-yyyy");
File.Move(file,string.Join(".", parts));
}
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다