ソース掲示板




すべてから検索

キーワード   条件 表示 現行ログ 過去ログ トピックス 名前 本文

  メンテナンス 前画面に戻る

対象スレッド 件名: C# : テキストファイル入力
名前: lightbox
処理選択
パスワード

件名 C# : テキストファイル入力
名前 lightbox
コメント
@SHOW
https://lh3.googleusercontent.com/-j0_lXXnpAds/WSJUSXVBEnI/AAAAAAAAkfU/cYtd5J3jph46PpovYKZR5QLeFqvgoQ3AgCHM/s352/_img.png
@END

@SHOW
https://msdn.microsoft.com/ja-jp/library/system.io.directory.getcurrentdirectory.aspx(Directory.GetCurrentDirectory メソッド)
※ 変更されていなければ、プロセスが開始された元のディレクトリです

https://msdn.microsoft.com/ja-jp/library/system.environment.currentdirectory.aspx(Environment.CurrentDirectory プロパティ)
@END

@DIV
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApplication1
{
    /// <summary>
    /// MainWindow.xaml の相互作用ロジック
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Console.WriteLine("クリックされました");
            Console.WriteLine(Directory.GetCurrentDirectory());

            FileStream fs = new FileStream(@"..\..\lib\data.csv", FileMode.Open);
            StreamReader sr = new StreamReader(fs, Encoding.GetEncoding("shift_jis"));

            String line;
            while (sr.Peek() >= 0) {
                line = sr.ReadLine();
                Console.WriteLine( line );
            }

            fs.Close();

        }
    }
}
@END