2016-09-06 3 views
-1

파일을 쓰는 데 streamwriter를 사용하고 있지만 새 작성된 파일의 위치는 프로젝트 폴더에있는 폴더 중 하나에 있지만 위치를 사용하고 싶습니다 컴퓨터의 문서 라이브러리 메신저 응용 프로그램 콘솔을 사용하여 메신저 응용 프로그램로컬 문서 라이브러리에 파일을 쓰는 방법

도움이 될 것입니다.

은 MSDN에서

using (var File = new StreamWriter(System.Web.HttpContext.Current.Server.MapPath("~/OutputFileTest.csv"), false)) // true for appending the file and false to overwrite the file 
      { 
       foreach (var item in outputFile) 
       { 
        File.WriteLine(item); 
       } 
      } 
+0

난 당신이 찾고있는 생각 : https://msdn.microsoft.com/en-us/library/system.environment .specialfolder (v = vs.110) .aspx –

+0

(var File = new StreamWriter (Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments) + "/OutputFileTest.csv", false)) // 파일을 추가하는 경우 true이고 false 인 경우 파일을 덮어 쓸 때 { foreach (outputFile의 var 항목) { File.WriteLine (item); } } –

+0

코드를 사용한 후 "시스템 환경에 특수 폴더 정의가 포함되어 있습니다"라는 오류 메시지가 표시됨 – user5813072

답변

0

감사합니다 :

// Sample for the Environment.GetFolderPath method 
using System; 

class Sample 
{ 
public static void Main() 
{ 
Console.WriteLine(); 
Console.WriteLine("GetFolderPath: {0}", 
      Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)); 
} 
} 
/* 
This example produces the following results: 

    */ 
관련 문제