I want to read cassandra scripts in a file. I give the file path but it points to another file. I want everyone working on the project to read from the file path.
I got this error:
System.IO.DirectoryNotFoundException: 'Could not find a part of the path 'C:\yedek\14.8.20 updaterdan önce\New folder\cross\Updater\bin\Debug\netcoreapp3.0\ABC\CassandraScripts\LiveScripts'.'
but the path I want to access is:
C:\yedek\14.8.20 updaterdan önce\New folder\cross\ABC\CassandraScripts\LiveScripts\
string[] fileList = File_Control("./ABC/CassandraScripts/LiveScripts/");
for (int i = 0; i < fileList.Length; i++)
{
char[] file_split = { '.', '/', '\\' };
//dosya yolunu parse eder.
string[] versionNameList = fileList[i].Split(file_split);
//script dosya ismini alır.
string versionName = versionNameList[versionNameList.Length - 1];
//script dosya ismini parse eder.
char[] char_split = { 'v', '.', '_'};
string[] version = versionName.Split(char_split);
string[] v = new string[3];
for (int j = 1; j < version.Length-2; j++)
{
v[j - 1] = version[j];
}
string vers = string.Concat(v);
public static string[] File_Control(string fileName)
{
string[] fileTest = Directory.GetFiles(@fileName);
return fileTest;
}
Resolved my problem:
string[] fileList = Directory.GetFiles("../../../../XYZ/CassandraScripts/LiveScripts/");
for (int i = 0; i < fileList.Length; i++)
{
char[] file_split = { '/', '\\' };
//dosya yolunu parse eder.
string[] versionNameList = fileList[i].Split(file_split);
//script dosya ismini alır.
string versionName = versionNameList[versionNameList.Length - 1];
//script dosya ismini parse eder.
char[] char_split = { 'v', '.', '_'};
string[] version = versionName.Split(char_split);
string[] v = new string[3];
for (int j = 1; j < version.Length-2; j++)
{
v[j - 1] = version[j];
}
string vers = string.Concat(v);