2012-11-06 4 views
0

나는 listbox을 가지고 있습니다. 다음 코드를 사용하여 txt 파일에 저장합니다.차트 저장 saveialog가있는 txt 파일

  String[] array = new String[listBox2.Items.Count]; 
      listBox2.Items.CopyTo(array, 0); 
      Microsoft.Win32.SaveFileDialog saveFileDialog1 = new Microsoft.Win32.SaveFileDialog(); 

      saveFileDialog1.FileName = "per_" ; 
      saveFileDialog1.DefaultExt = ".txt"; 
      saveFileDialog1.Filter = "Text files (.txt)|*.txt"; 

      Nullable<bool> res = saveFileDialog1.ShowDialog(); 

      if (res == true) 
      { 
       string filename = saveFileDialog1.FileName; 

       File.WriteAllLines(filename, array, Encoding.UTF8); 

       MessageBox.Show("File saved successfully"); 
      } 

나는 C에 차트를 저장합니다 : //

chart2.SaveImage("C://", System.Drawing.Imaging.ImageFormat.Jpeg); 

그러나 나는 사용자가 savefiledialog로 chosed 같은 방향에서 내 차트를 저장합니다. 이것을 관리하려면 어떻게해야합니까?

+0

이 필요하거나 가능한 추가 목록 상자 및 JPEG 하나 개의 파일에서 PDF로 경우

chart2.SaveImage(Path.GetDirectoryName(saveFileDialog1.FileName) + "\\chart.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); 

? – Oktay

답변

0

는 시도이

chart2.SaveImage(Path.GetDirectoryName(saveFileDialog1.FileName), System.Drawing.Imaging.ImageFormat.Jpeg); 

또는이 SaveImage 방법은 파일 이름