C# 프로그램에서 csv 파일을 열고 읽는 중 여기에 멈추었습니다. 필자는 3D 매트릭스 그래프를 표시하기 위해 ILNumerics 작업을 시작했지만 예외는 "C : \ Users \ asd \ Documents \ Visual Studio 2013 \ Projects \ matrixgraph \ martix \ bin \ Debug \ stats 파일을 찾을 수 없습니다. csv '. "C#에서 csv 파일을 여는 중 오류가 발생했습니다.
도와주세요! 다음은 코드입니다.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using ILNumerics;
using ILNumerics.Drawing;
using ILNumerics.Drawing.Plotting;
namespace martix
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void ilPanel1_Load(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
string path = @"C:\Users\asd\Documents\Visual Studio 2013\Projects\matrixgraph\martix\bin\Debug\stats.csv";
StreamReader sr = new StreamReader(File.Open(path, FileMode.Open));
string dataLines = string.Empty;
while (sr.Peek() != -1)
dataLines += sr.ReadLine().Replace(";", ",") + "\n";
sr.Close();
dataLines = dataLines.Trim('\n');
//Convert the data-string into an ILArray
ILArray<int> AN = ILMath.csvread<int>(dataLines);
//Create a new scene, which is the base for our graph
var scene = new ILScene();
using (ILScope.Enter())
{
//Convert all data points to float
ILArray<float> A = ILMath.tosingle(AN);
//Add a plot to the scene and configure it
scene.Add(new ILPlotCube
{
//Render in 3D
TwoDMode = false,
//Add 3 axes
Axes =
{
XAxis =
{
Label = { Text = "Price in $" },
GridMajor =
{
DashStyle = DashStyle.Dashed,
Color = Color.DarkGray,
Width = 1
}
},
YAxis =
{
Label = { Text = "Rating count" },
GridMajor =
{
DashStyle = DashStyle.Dashed,
Color = Color.DarkGray,
Width = 1
}
},
ZAxis =
{
Label = { Text = "Download count" }
}
},
//Add the data points
Children = {
new ILPoints {
Positions = A
},
},
//Set start rotation for 3D rendered graph
Rotation = Matrix4.Rotation(new Vector3(1, 1, 1), 0.5f)
});
}
//Add the scene to the ILPanel
ilPanel1.Scene = scene;
}
}
}
'stats.csv' 파일이'bin \ debug'에 없습니다. VS에서 프로젝트를 참조하는 경우'Properties -> Copy to Output Directory'가 항상 복사하거나 최신 일 경우 복사 –
글쎄, 나는 이것을 여러 번 만들었지 만 여전히 나에게 오류를 준다. – Mikka
"matrix"대신 디렉토리가 실제로 "martix"입니까? 또한, [응용 프로그램 폴더 경로를 얻는 가장 좋은 방법은] (http://stackoverflow.com/q/6041332/1115360) 도움이 될 수 있습니다. –