일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- C#
- programmers
- IValueConverter
- string
- .net
- dotNET
- log
- git
- Coding
- commit
- Github
- windows
- nullable
- Microsoft
- 코딩테스트
- coding-test
- Process
- algorithm
- windows10
- ListView
- mysql
- chashtag
- WPF
- csharp
- logging
- File
- Visual Studio
- convert
- tls
- Binding
- Today
- Total
목록File (6)
CHashtag
안녕하세요. C#에서 Logging을 구현할 때 대부분 라이브러리를 사용하여 구현합니다. 저는 그중에서도 많이 쓰이는 라이브러리인 log4net을 주로 사용하는데, log4net은 config을 참조하여 logging에 관한 정보를 얻습니다. log를 저장할 경로이나, logging level, 한 파일 크기, pattern등을 말이죠. 그러나 어떠한 이유로 config를 만들 수 없는 상황이 간혹 오는데요, 예를들면, 하나의 exe로 packaging을 해야 한다거나,, 그럴 때 유용하여 사용할 수 있는 방법에 대해 알려드리고자 합니다. 방법은 간단한데요, 아래 코드는 log4net.config를 c#코드로 구현한 것입니다. 해당 코드를 프로그램 시작점에서 실행시켜 주시면 log4net.config를 ..
안녕하세요. 오늘은 파일을 점유하되(Write), 다른 프로세스가 해당 파일을 읽을(Read) 수 있는 방법에 대해 알아보도록 하겠습니다. File.Open File.Open 함수는 최대 4개의 인자(Parameter)를 받도록 되어있습니다. 우선 인자에 대해 간략하게 설명해드리고, 해당 인자들을 혼합하여 파일을 여는 방법에 대하여 설명해 드리겠습니다. Arguments path 말 그대로 Open 할 파일의 경로입니다. fileMode Path의 파일을 가지고 할 행동을 나타냅니다. FileMode enum은 아래와 같습니다. [관련 링크] CreateNew 파일을 새로 만들지만, 이미 있으면 에러가 납니다. Create path에 파일을 새로 만들고, 해당 경로에 파일이 이미 존재한다면 덮어 씌웁니다..
안녕하세요. 오늘은 개별 파일 크기를 구하는 방법에 대해 알아보도록 하겠습니다. 간단한 내용이니 별도의 내용 없이 코드로 보여드리겠습니다. 해당 크기는 디스크 할당 크기가 아닌 그냥 크기 임을 알려드리고 디스크 크기 구하는 방법은 다른 게시글로 정리하도록 하겠습니다. public long GetFileSize(string filePath) { long fileSize = 0; if(File.Exists(filePath)) { FileInfo info = new FileInfo(filePath); fileSize = info.Length; } return fileSize; } 감사합니다.
결론부터 알려드리겠습니다. public string[] SelectMultiFiles(string defaultPath) { string[] selectPath = null; var openFileDialog = new OpenFileDialog(); openFileDialog.Multiselect = true; if (Directory.Exists(defaultPath)) { openFileDialog.InitialDirectory = defaultPath; } else { openFileDialog.InitialDirectory = @"C:\"; } bool? result = openFileDialog.ShowDialog(); if (result.HasValue && result.Value) { se..
오늘은 폴더를 zip 파일로, zip 파일을 폴더로 만드는 방법에 대해 알아보겠습니다. 아래 코드를 구현하기 위해선 System.IO.Compression.FileSystem을 Reference에 추가하여야 합니다. static void Main(string[] args) { string directoryPath = @"D:\Record"; string zipPath = @"D:\Record.zip"; string unzipPath = @"D:\UnzipRecord"; bool zipResult = ZipDirectory(directoryPath, zipPath); bool unzipResult = UnzipFile(zipPath, unzipPath); } public static bool ZipDire..
using System.Collections.Generic; using System.IO; using System.Text; namespace CHashtag { class FileIO { static void Main(string[] args) { string inputFilePath = @"c:\temp\input.txt"; string outputFilePath = @"c:\temp\output.txt"; var inputArr = File.ReadAllLines(inputFilePath, Encoding.UTF8); // change array to list var inputList = new List(inputArr); List outputList = new List(); inputList.Fo..