修复读写bug
This commit is contained in:
@ -5,6 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace mainProgram
|
||||
{
|
||||
@ -60,9 +61,33 @@ namespace mainProgram
|
||||
|
||||
}
|
||||
|
||||
public void OpenProject()
|
||||
public void OpenProject(string projectPath)
|
||||
{
|
||||
mProjectPath = projectPath;
|
||||
|
||||
mMetadataPath = Path.Combine(mProjectPath, ".project");
|
||||
mRawPath = Path.Combine(mProjectPath, "1raw");
|
||||
mRadPath = Path.Combine(mProjectPath, "2rad");
|
||||
mSifPath = Path.Combine(mProjectPath, "3sif");
|
||||
|
||||
//if (false == Directory.Exists(mMetadataPath))
|
||||
//{
|
||||
// Directory.CreateDirectory(mMetadataPath);
|
||||
|
||||
// MessageBox.Show("工程打开成功!", "提示");
|
||||
//}
|
||||
//if (false == Directory.Exists(mRawPath))
|
||||
//{
|
||||
// Directory.CreateDirectory(mRawPath);
|
||||
//}
|
||||
//if (false == Directory.Exists(mRadPath))
|
||||
//{
|
||||
// Directory.CreateDirectory(mRadPath);
|
||||
//}
|
||||
//if (false == Directory.Exists(mSifPath))
|
||||
//{
|
||||
// Directory.CreateDirectory(mSifPath);
|
||||
//}
|
||||
}
|
||||
|
||||
public void SaveProject()
|
||||
@ -354,31 +379,50 @@ namespace mainProgram
|
||||
//处理工程中的数据
|
||||
public void Rad()
|
||||
{
|
||||
//string[] sourceFilesPath = Directory.GetFileSystemEntries(sourceFolderName);
|
||||
Console.WriteLine("工程目录为" + mProjectPath);
|
||||
|
||||
//for (int i = 0; i < sourceFilesPath.Length; i++)
|
||||
//{
|
||||
// string sourceFilePath = sourceFilesPath[i];
|
||||
// string[] forlders = sourceFilePath.Split('\\');
|
||||
DelectDir(mRadPath);
|
||||
|
||||
// if (File.Exists(sourceFilePath))//是文件,直接拷贝
|
||||
// {
|
||||
// string dest = destFolderName;
|
||||
// string sourceFileName = Path.GetFileName(sourceFilePath);//获取文件名
|
||||
// File.Copy(sourceFilePath, Path.Combine(dest, sourceFileName), overwrite);
|
||||
// }
|
||||
// else if (Directory.Exists(sourceFilePath))//是文件夹,拷贝文件夹;并递归
|
||||
// {
|
||||
// string lastDirectory = forlders[forlders.Length - 1];
|
||||
// string dest = Path.Combine(destFolderName, lastDirectory);
|
||||
string[] sourceFilesPath = Directory.GetFileSystemEntries(mRawPath);
|
||||
|
||||
// if (!Directory.Exists(dest))
|
||||
// {
|
||||
// Directory.CreateDirectory(dest);
|
||||
// }
|
||||
// CopySubFun(sourceFilePath, dest, overwrite);
|
||||
// }
|
||||
//}
|
||||
for (int i = 0; i < sourceFilesPath.Length; i++)
|
||||
{
|
||||
string sourceFilePath = sourceFilesPath[i];
|
||||
string[] forlders = sourceFilePath.Split('\\');
|
||||
|
||||
string lastDirectory = forlders[forlders.Length - 1];
|
||||
string dest = Path.Combine(mRadPath, lastDirectory);
|
||||
|
||||
if (!Directory.Exists(dest))
|
||||
{
|
||||
Directory.CreateDirectory(dest);
|
||||
}
|
||||
//福亮度转换
|
||||
string[] rawFiles = Directory.GetFileSystemEntries(Path.Combine(mRawPath, lastDirectory));
|
||||
|
||||
foreach (string rawFileName in rawFiles)//文件夹下的文件
|
||||
{
|
||||
string[] nameTmp = rawFileName.Split('\\');
|
||||
|
||||
string name = nameTmp[nameTmp.Length - 1];
|
||||
SpectralDataReaderWriter SpectralData = new SpectralDataReaderWriter(rawFileName);
|
||||
for (int j = 1; j <= SpectralData.TotalSpectralCount; j++)//处理 csv文件中的每条光谱
|
||||
{
|
||||
SpectralData tmp1 = SpectralData.GetSpectral(j);
|
||||
for (int ii = 0; ii < tmp1.spectralDataLength; ii++)
|
||||
{
|
||||
tmp1.spectral[ii] = j;
|
||||
}
|
||||
SpectralData.UpdateSpectral(j, tmp1);
|
||||
|
||||
|
||||
}
|
||||
|
||||
string destFileName = Path.Combine(dest, name);
|
||||
SpectralData.SaveCSV(destFileName);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user