File.Create() method fails when part of path does not exist [duplicate]

Multi tool use
This question already has an answer here:
How do I create a file AND any folders, if the folders don't exist?
9 answers
I've been writing a simple console application as a part of exercise in project. Tasks are rather straightforward:
2nd method has to create nested directory tree where every folder name is Guid.
3rd method has to put empty file in chosen directory tree at specific level.
My main problem lies within 3rd method. Because while it works fine and creates file 'till third level of any directory, beyond that point it always throw "System.IO.DirectoryNotFoundException" - as it "can't find part of the path".
I use string as a container for path, but since it's few Guid set together it gets pretty long. I had similar problem with creating directory, but in order to work I had to simply put @"?" prefix behind the path. So is there any way to make it work, or maybe get around that?
Here are method that fails. Specifically it's
File.Create(PathToFile + @"blank.txt").Dispose();
And part of code which makes string and invokes it:
string ChosenDirectoryPath = currDir.FullName + @"";
for (int i = 0; i <= Position; i++)
{
ChosenDirectoryPath += ListsList[WhichList][i];
}
if (!File.Exists(ChosenDirectoryPath + @"blank.txt"))
{
FileMaker(ref ChosenDirectoryPath);
}
Edit:
To be specific, directories are made by method:
public List<string> DirectoryList = new List<string>();
internal static List<List<string>> ListsList = new List<List<string>>();
private static DirectoryInfo currDir = new DirectoryInfo(".");
private string FolderName;
private static string DirectoryPath;
public void DeepDive(List<string> DirectoryList, int countdown)
{
FolderName = GuidMaker();
DirectoryList.Add(FolderName + @"");
if (countdown <= 1)
{
foreach (string element in DirectoryList)
{
DirectoryPath += element;
}
Directory.CreateDirectory(@"\?" + currDir.FullName + @"" + DirectoryPath);
Console.WriteLine("Folders were nested at directory {0} under folder {1}n", currDir.FullName, DirectoryList[0]);
ListsList.Add(DirectoryList);
DirectoryPath = null;
return;
}
DeepDive(DirectoryList, countdown-1);
}
Which is pretty messy because of recursion (iteration would be better but i wanted to do it this way to learn something). The point is that directories are made and stored in list of lists.
Creating files works properly but only for the first three nested folders. So the problem is that it is somehow loosing it's path to file in 4th and 5th level, and can't even make those manually. Could it be too long path? And how to fix this.
Here is exception that throws out:
System.IO.DirectoryNotFoundException: „Can't find part of the path
„C:SomeMoreFolders1b0c7715-ee01-4df8-9079-82ea7990030fc6c806b0-b69d-4a3a-88d0-1bd8a0e31eb29671f2b3-3041-42d5-b631-4719d36c2ac56406f00f-7750-4b5a-a45d-cebcecb0b70ebcacef2b-e391-4799-b84e-f2bc55605d40blank.txt”.”
So it throws full path to file and yet says that it can't find it.
c# createfile
marked as duplicate by Alexei Levenkov
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 1 at 1:05
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
How do I create a file AND any folders, if the folders don't exist?
9 answers
I've been writing a simple console application as a part of exercise in project. Tasks are rather straightforward:
2nd method has to create nested directory tree where every folder name is Guid.
3rd method has to put empty file in chosen directory tree at specific level.
My main problem lies within 3rd method. Because while it works fine and creates file 'till third level of any directory, beyond that point it always throw "System.IO.DirectoryNotFoundException" - as it "can't find part of the path".
I use string as a container for path, but since it's few Guid set together it gets pretty long. I had similar problem with creating directory, but in order to work I had to simply put @"?" prefix behind the path. So is there any way to make it work, or maybe get around that?
Here are method that fails. Specifically it's
File.Create(PathToFile + @"blank.txt").Dispose();
And part of code which makes string and invokes it:
string ChosenDirectoryPath = currDir.FullName + @"";
for (int i = 0; i <= Position; i++)
{
ChosenDirectoryPath += ListsList[WhichList][i];
}
if (!File.Exists(ChosenDirectoryPath + @"blank.txt"))
{
FileMaker(ref ChosenDirectoryPath);
}
Edit:
To be specific, directories are made by method:
public List<string> DirectoryList = new List<string>();
internal static List<List<string>> ListsList = new List<List<string>>();
private static DirectoryInfo currDir = new DirectoryInfo(".");
private string FolderName;
private static string DirectoryPath;
public void DeepDive(List<string> DirectoryList, int countdown)
{
FolderName = GuidMaker();
DirectoryList.Add(FolderName + @"");
if (countdown <= 1)
{
foreach (string element in DirectoryList)
{
DirectoryPath += element;
}
Directory.CreateDirectory(@"\?" + currDir.FullName + @"" + DirectoryPath);
Console.WriteLine("Folders were nested at directory {0} under folder {1}n", currDir.FullName, DirectoryList[0]);
ListsList.Add(DirectoryList);
DirectoryPath = null;
return;
}
DeepDive(DirectoryList, countdown-1);
}
Which is pretty messy because of recursion (iteration would be better but i wanted to do it this way to learn something). The point is that directories are made and stored in list of lists.
Creating files works properly but only for the first three nested folders. So the problem is that it is somehow loosing it's path to file in 4th and 5th level, and can't even make those manually. Could it be too long path? And how to fix this.
Here is exception that throws out:
System.IO.DirectoryNotFoundException: „Can't find part of the path
„C:SomeMoreFolders1b0c7715-ee01-4df8-9079-82ea7990030fc6c806b0-b69d-4a3a-88d0-1bd8a0e31eb29671f2b3-3041-42d5-b631-4719d36c2ac56406f00f-7750-4b5a-a45d-cebcecb0b70ebcacef2b-e391-4799-b84e-f2bc55605d40blank.txt”.”
So it throws full path to file and yet says that it can't find it.
c# createfile
marked as duplicate by Alexei Levenkov
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 1 at 1:05
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
currDir.FullName + @"" + @"blank.txt" wouldnt that give you two on your path?. You shoud be using Path.Combine(path1,path2) to go aroudn merging paths and the "" that can be duplicated if both paths contain the ""
– npo
Dec 30 '18 at 20:48
Thanks for pointing out, as soon as i figure out how to use it i'll try to, but for now I'm concerned more about the thing that the way I implemented it works, but only for directories which are not deeper than 3rd folder.
– Raczy
Dec 30 '18 at 22:50
add a comment |
This question already has an answer here:
How do I create a file AND any folders, if the folders don't exist?
9 answers
I've been writing a simple console application as a part of exercise in project. Tasks are rather straightforward:
2nd method has to create nested directory tree where every folder name is Guid.
3rd method has to put empty file in chosen directory tree at specific level.
My main problem lies within 3rd method. Because while it works fine and creates file 'till third level of any directory, beyond that point it always throw "System.IO.DirectoryNotFoundException" - as it "can't find part of the path".
I use string as a container for path, but since it's few Guid set together it gets pretty long. I had similar problem with creating directory, but in order to work I had to simply put @"?" prefix behind the path. So is there any way to make it work, or maybe get around that?
Here are method that fails. Specifically it's
File.Create(PathToFile + @"blank.txt").Dispose();
And part of code which makes string and invokes it:
string ChosenDirectoryPath = currDir.FullName + @"";
for (int i = 0; i <= Position; i++)
{
ChosenDirectoryPath += ListsList[WhichList][i];
}
if (!File.Exists(ChosenDirectoryPath + @"blank.txt"))
{
FileMaker(ref ChosenDirectoryPath);
}
Edit:
To be specific, directories are made by method:
public List<string> DirectoryList = new List<string>();
internal static List<List<string>> ListsList = new List<List<string>>();
private static DirectoryInfo currDir = new DirectoryInfo(".");
private string FolderName;
private static string DirectoryPath;
public void DeepDive(List<string> DirectoryList, int countdown)
{
FolderName = GuidMaker();
DirectoryList.Add(FolderName + @"");
if (countdown <= 1)
{
foreach (string element in DirectoryList)
{
DirectoryPath += element;
}
Directory.CreateDirectory(@"\?" + currDir.FullName + @"" + DirectoryPath);
Console.WriteLine("Folders were nested at directory {0} under folder {1}n", currDir.FullName, DirectoryList[0]);
ListsList.Add(DirectoryList);
DirectoryPath = null;
return;
}
DeepDive(DirectoryList, countdown-1);
}
Which is pretty messy because of recursion (iteration would be better but i wanted to do it this way to learn something). The point is that directories are made and stored in list of lists.
Creating files works properly but only for the first three nested folders. So the problem is that it is somehow loosing it's path to file in 4th and 5th level, and can't even make those manually. Could it be too long path? And how to fix this.
Here is exception that throws out:
System.IO.DirectoryNotFoundException: „Can't find part of the path
„C:SomeMoreFolders1b0c7715-ee01-4df8-9079-82ea7990030fc6c806b0-b69d-4a3a-88d0-1bd8a0e31eb29671f2b3-3041-42d5-b631-4719d36c2ac56406f00f-7750-4b5a-a45d-cebcecb0b70ebcacef2b-e391-4799-b84e-f2bc55605d40blank.txt”.”
So it throws full path to file and yet says that it can't find it.
c# createfile
This question already has an answer here:
How do I create a file AND any folders, if the folders don't exist?
9 answers
I've been writing a simple console application as a part of exercise in project. Tasks are rather straightforward:
2nd method has to create nested directory tree where every folder name is Guid.
3rd method has to put empty file in chosen directory tree at specific level.
My main problem lies within 3rd method. Because while it works fine and creates file 'till third level of any directory, beyond that point it always throw "System.IO.DirectoryNotFoundException" - as it "can't find part of the path".
I use string as a container for path, but since it's few Guid set together it gets pretty long. I had similar problem with creating directory, but in order to work I had to simply put @"?" prefix behind the path. So is there any way to make it work, or maybe get around that?
Here are method that fails. Specifically it's
File.Create(PathToFile + @"blank.txt").Dispose();
And part of code which makes string and invokes it:
string ChosenDirectoryPath = currDir.FullName + @"";
for (int i = 0; i <= Position; i++)
{
ChosenDirectoryPath += ListsList[WhichList][i];
}
if (!File.Exists(ChosenDirectoryPath + @"blank.txt"))
{
FileMaker(ref ChosenDirectoryPath);
}
Edit:
To be specific, directories are made by method:
public List<string> DirectoryList = new List<string>();
internal static List<List<string>> ListsList = new List<List<string>>();
private static DirectoryInfo currDir = new DirectoryInfo(".");
private string FolderName;
private static string DirectoryPath;
public void DeepDive(List<string> DirectoryList, int countdown)
{
FolderName = GuidMaker();
DirectoryList.Add(FolderName + @"");
if (countdown <= 1)
{
foreach (string element in DirectoryList)
{
DirectoryPath += element;
}
Directory.CreateDirectory(@"\?" + currDir.FullName + @"" + DirectoryPath);
Console.WriteLine("Folders were nested at directory {0} under folder {1}n", currDir.FullName, DirectoryList[0]);
ListsList.Add(DirectoryList);
DirectoryPath = null;
return;
}
DeepDive(DirectoryList, countdown-1);
}
Which is pretty messy because of recursion (iteration would be better but i wanted to do it this way to learn something). The point is that directories are made and stored in list of lists.
Creating files works properly but only for the first three nested folders. So the problem is that it is somehow loosing it's path to file in 4th and 5th level, and can't even make those manually. Could it be too long path? And how to fix this.
Here is exception that throws out:
System.IO.DirectoryNotFoundException: „Can't find part of the path
„C:SomeMoreFolders1b0c7715-ee01-4df8-9079-82ea7990030fc6c806b0-b69d-4a3a-88d0-1bd8a0e31eb29671f2b3-3041-42d5-b631-4719d36c2ac56406f00f-7750-4b5a-a45d-cebcecb0b70ebcacef2b-e391-4799-b84e-f2bc55605d40blank.txt”.”
So it throws full path to file and yet says that it can't find it.
This question already has an answer here:
How do I create a file AND any folders, if the folders don't exist?
9 answers
c# createfile
c# createfile
edited Jan 1 at 1:05
Alexei Levenkov
84.5k890136
84.5k890136
asked Dec 30 '18 at 20:43


RaczyRaczy
84
84
marked as duplicate by Alexei Levenkov
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 1 at 1:05
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Alexei Levenkov
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Jan 1 at 1:05
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
currDir.FullName + @"" + @"blank.txt" wouldnt that give you two on your path?. You shoud be using Path.Combine(path1,path2) to go aroudn merging paths and the "" that can be duplicated if both paths contain the ""
– npo
Dec 30 '18 at 20:48
Thanks for pointing out, as soon as i figure out how to use it i'll try to, but for now I'm concerned more about the thing that the way I implemented it works, but only for directories which are not deeper than 3rd folder.
– Raczy
Dec 30 '18 at 22:50
add a comment |
1
currDir.FullName + @"" + @"blank.txt" wouldnt that give you two on your path?. You shoud be using Path.Combine(path1,path2) to go aroudn merging paths and the "" that can be duplicated if both paths contain the ""
– npo
Dec 30 '18 at 20:48
Thanks for pointing out, as soon as i figure out how to use it i'll try to, but for now I'm concerned more about the thing that the way I implemented it works, but only for directories which are not deeper than 3rd folder.
– Raczy
Dec 30 '18 at 22:50
1
1
currDir.FullName + @"" + @"blank.txt" wouldnt that give you two on your path?. You shoud be using Path.Combine(path1,path2) to go aroudn merging paths and the "" that can be duplicated if both paths contain the ""
– npo
Dec 30 '18 at 20:48
currDir.FullName + @"" + @"blank.txt" wouldnt that give you two on your path?. You shoud be using Path.Combine(path1,path2) to go aroudn merging paths and the "" that can be duplicated if both paths contain the ""
– npo
Dec 30 '18 at 20:48
Thanks for pointing out, as soon as i figure out how to use it i'll try to, but for now I'm concerned more about the thing that the way I implemented it works, but only for directories which are not deeper than 3rd folder.
– Raczy
Dec 30 '18 at 22:50
Thanks for pointing out, as soon as i figure out how to use it i'll try to, but for now I'm concerned more about the thing that the way I implemented it works, but only for directories which are not deeper than 3rd folder.
– Raczy
Dec 30 '18 at 22:50
add a comment |
1 Answer
1
active
oldest
votes
You problem is that File.Create
doesn't create the corresponding directories for you, instead it throws a System.IO.DirectoryNotFoundException
.
You have to create those directories yourself, by using System.IO.Directory.CreateDirectory()
If this exception occurs because of a too long path, you can still use the "long path syntax (\?)" like you did when creating your directories.
See also this question: How to deal with files with a name longer than 259 characters? there is also a good article linked
Thank you for answer, yet these directories are created earlier by another method which i didn't post here. This method usesSystem.IO.Directory.CreateDirectory()
as you advise, and I actually can create some files, but only in directories which are not nested deeper than at 3rd level. While I get Exception it shows me accurate path to the place where I want this file to be made, except that it doesn't create it. Even as i give path manually it still throws that error.
– Raczy
Dec 30 '18 at 22:48
@Raczy Thats weird cause the path you mentioned doesn't exceed any limit. I triedFile.Create
with the exact same path and everything works fine for me. Are you 100% sure that all the directories exists?
– nosale
Dec 31 '18 at 14:41
Once again I carefully looked over whole path and everything seemed fine.I decided to do it manually, creating every file step by step. So again for the first three nested files everything worked fine. Was doing it via copy-paste and checking it with file explorer to be sure that path is the same, and again the same problem took place. Exception for not complete path is thrown at the 4th and 5th nested directory (VS is in admin mode). I think I'll just pass it. Maybe it's just my personal problem. Yet it seems pretty strange. Anyway thanks for the efford
– Raczy
Dec 31 '18 at 18:42
@Raczy I looked into your github repository and found your source code there, based on that I have edit my answer, which hopefully helps you
– nosale
Dec 31 '18 at 20:04
That's a real hero right there, thank you very much for your efford!
– Raczy
Dec 31 '18 at 20:26
|
show 2 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You problem is that File.Create
doesn't create the corresponding directories for you, instead it throws a System.IO.DirectoryNotFoundException
.
You have to create those directories yourself, by using System.IO.Directory.CreateDirectory()
If this exception occurs because of a too long path, you can still use the "long path syntax (\?)" like you did when creating your directories.
See also this question: How to deal with files with a name longer than 259 characters? there is also a good article linked
Thank you for answer, yet these directories are created earlier by another method which i didn't post here. This method usesSystem.IO.Directory.CreateDirectory()
as you advise, and I actually can create some files, but only in directories which are not nested deeper than at 3rd level. While I get Exception it shows me accurate path to the place where I want this file to be made, except that it doesn't create it. Even as i give path manually it still throws that error.
– Raczy
Dec 30 '18 at 22:48
@Raczy Thats weird cause the path you mentioned doesn't exceed any limit. I triedFile.Create
with the exact same path and everything works fine for me. Are you 100% sure that all the directories exists?
– nosale
Dec 31 '18 at 14:41
Once again I carefully looked over whole path and everything seemed fine.I decided to do it manually, creating every file step by step. So again for the first three nested files everything worked fine. Was doing it via copy-paste and checking it with file explorer to be sure that path is the same, and again the same problem took place. Exception for not complete path is thrown at the 4th and 5th nested directory (VS is in admin mode). I think I'll just pass it. Maybe it's just my personal problem. Yet it seems pretty strange. Anyway thanks for the efford
– Raczy
Dec 31 '18 at 18:42
@Raczy I looked into your github repository and found your source code there, based on that I have edit my answer, which hopefully helps you
– nosale
Dec 31 '18 at 20:04
That's a real hero right there, thank you very much for your efford!
– Raczy
Dec 31 '18 at 20:26
|
show 2 more comments
You problem is that File.Create
doesn't create the corresponding directories for you, instead it throws a System.IO.DirectoryNotFoundException
.
You have to create those directories yourself, by using System.IO.Directory.CreateDirectory()
If this exception occurs because of a too long path, you can still use the "long path syntax (\?)" like you did when creating your directories.
See also this question: How to deal with files with a name longer than 259 characters? there is also a good article linked
Thank you for answer, yet these directories are created earlier by another method which i didn't post here. This method usesSystem.IO.Directory.CreateDirectory()
as you advise, and I actually can create some files, but only in directories which are not nested deeper than at 3rd level. While I get Exception it shows me accurate path to the place where I want this file to be made, except that it doesn't create it. Even as i give path manually it still throws that error.
– Raczy
Dec 30 '18 at 22:48
@Raczy Thats weird cause the path you mentioned doesn't exceed any limit. I triedFile.Create
with the exact same path and everything works fine for me. Are you 100% sure that all the directories exists?
– nosale
Dec 31 '18 at 14:41
Once again I carefully looked over whole path and everything seemed fine.I decided to do it manually, creating every file step by step. So again for the first three nested files everything worked fine. Was doing it via copy-paste and checking it with file explorer to be sure that path is the same, and again the same problem took place. Exception for not complete path is thrown at the 4th and 5th nested directory (VS is in admin mode). I think I'll just pass it. Maybe it's just my personal problem. Yet it seems pretty strange. Anyway thanks for the efford
– Raczy
Dec 31 '18 at 18:42
@Raczy I looked into your github repository and found your source code there, based on that I have edit my answer, which hopefully helps you
– nosale
Dec 31 '18 at 20:04
That's a real hero right there, thank you very much for your efford!
– Raczy
Dec 31 '18 at 20:26
|
show 2 more comments
You problem is that File.Create
doesn't create the corresponding directories for you, instead it throws a System.IO.DirectoryNotFoundException
.
You have to create those directories yourself, by using System.IO.Directory.CreateDirectory()
If this exception occurs because of a too long path, you can still use the "long path syntax (\?)" like you did when creating your directories.
See also this question: How to deal with files with a name longer than 259 characters? there is also a good article linked
You problem is that File.Create
doesn't create the corresponding directories for you, instead it throws a System.IO.DirectoryNotFoundException
.
You have to create those directories yourself, by using System.IO.Directory.CreateDirectory()
If this exception occurs because of a too long path, you can still use the "long path syntax (\?)" like you did when creating your directories.
See also this question: How to deal with files with a name longer than 259 characters? there is also a good article linked
edited Dec 31 '18 at 20:03
answered Dec 30 '18 at 21:34
nosalenosale
642212
642212
Thank you for answer, yet these directories are created earlier by another method which i didn't post here. This method usesSystem.IO.Directory.CreateDirectory()
as you advise, and I actually can create some files, but only in directories which are not nested deeper than at 3rd level. While I get Exception it shows me accurate path to the place where I want this file to be made, except that it doesn't create it. Even as i give path manually it still throws that error.
– Raczy
Dec 30 '18 at 22:48
@Raczy Thats weird cause the path you mentioned doesn't exceed any limit. I triedFile.Create
with the exact same path and everything works fine for me. Are you 100% sure that all the directories exists?
– nosale
Dec 31 '18 at 14:41
Once again I carefully looked over whole path and everything seemed fine.I decided to do it manually, creating every file step by step. So again for the first three nested files everything worked fine. Was doing it via copy-paste and checking it with file explorer to be sure that path is the same, and again the same problem took place. Exception for not complete path is thrown at the 4th and 5th nested directory (VS is in admin mode). I think I'll just pass it. Maybe it's just my personal problem. Yet it seems pretty strange. Anyway thanks for the efford
– Raczy
Dec 31 '18 at 18:42
@Raczy I looked into your github repository and found your source code there, based on that I have edit my answer, which hopefully helps you
– nosale
Dec 31 '18 at 20:04
That's a real hero right there, thank you very much for your efford!
– Raczy
Dec 31 '18 at 20:26
|
show 2 more comments
Thank you for answer, yet these directories are created earlier by another method which i didn't post here. This method usesSystem.IO.Directory.CreateDirectory()
as you advise, and I actually can create some files, but only in directories which are not nested deeper than at 3rd level. While I get Exception it shows me accurate path to the place where I want this file to be made, except that it doesn't create it. Even as i give path manually it still throws that error.
– Raczy
Dec 30 '18 at 22:48
@Raczy Thats weird cause the path you mentioned doesn't exceed any limit. I triedFile.Create
with the exact same path and everything works fine for me. Are you 100% sure that all the directories exists?
– nosale
Dec 31 '18 at 14:41
Once again I carefully looked over whole path and everything seemed fine.I decided to do it manually, creating every file step by step. So again for the first three nested files everything worked fine. Was doing it via copy-paste and checking it with file explorer to be sure that path is the same, and again the same problem took place. Exception for not complete path is thrown at the 4th and 5th nested directory (VS is in admin mode). I think I'll just pass it. Maybe it's just my personal problem. Yet it seems pretty strange. Anyway thanks for the efford
– Raczy
Dec 31 '18 at 18:42
@Raczy I looked into your github repository and found your source code there, based on that I have edit my answer, which hopefully helps you
– nosale
Dec 31 '18 at 20:04
That's a real hero right there, thank you very much for your efford!
– Raczy
Dec 31 '18 at 20:26
Thank you for answer, yet these directories are created earlier by another method which i didn't post here. This method uses
System.IO.Directory.CreateDirectory()
as you advise, and I actually can create some files, but only in directories which are not nested deeper than at 3rd level. While I get Exception it shows me accurate path to the place where I want this file to be made, except that it doesn't create it. Even as i give path manually it still throws that error.– Raczy
Dec 30 '18 at 22:48
Thank you for answer, yet these directories are created earlier by another method which i didn't post here. This method uses
System.IO.Directory.CreateDirectory()
as you advise, and I actually can create some files, but only in directories which are not nested deeper than at 3rd level. While I get Exception it shows me accurate path to the place where I want this file to be made, except that it doesn't create it. Even as i give path manually it still throws that error.– Raczy
Dec 30 '18 at 22:48
@Raczy Thats weird cause the path you mentioned doesn't exceed any limit. I tried
File.Create
with the exact same path and everything works fine for me. Are you 100% sure that all the directories exists?– nosale
Dec 31 '18 at 14:41
@Raczy Thats weird cause the path you mentioned doesn't exceed any limit. I tried
File.Create
with the exact same path and everything works fine for me. Are you 100% sure that all the directories exists?– nosale
Dec 31 '18 at 14:41
Once again I carefully looked over whole path and everything seemed fine.I decided to do it manually, creating every file step by step. So again for the first three nested files everything worked fine. Was doing it via copy-paste and checking it with file explorer to be sure that path is the same, and again the same problem took place. Exception for not complete path is thrown at the 4th and 5th nested directory (VS is in admin mode). I think I'll just pass it. Maybe it's just my personal problem. Yet it seems pretty strange. Anyway thanks for the efford
– Raczy
Dec 31 '18 at 18:42
Once again I carefully looked over whole path and everything seemed fine.I decided to do it manually, creating every file step by step. So again for the first three nested files everything worked fine. Was doing it via copy-paste and checking it with file explorer to be sure that path is the same, and again the same problem took place. Exception for not complete path is thrown at the 4th and 5th nested directory (VS is in admin mode). I think I'll just pass it. Maybe it's just my personal problem. Yet it seems pretty strange. Anyway thanks for the efford
– Raczy
Dec 31 '18 at 18:42
@Raczy I looked into your github repository and found your source code there, based on that I have edit my answer, which hopefully helps you
– nosale
Dec 31 '18 at 20:04
@Raczy I looked into your github repository and found your source code there, based on that I have edit my answer, which hopefully helps you
– nosale
Dec 31 '18 at 20:04
That's a real hero right there, thank you very much for your efford!
– Raczy
Dec 31 '18 at 20:26
That's a real hero right there, thank you very much for your efford!
– Raczy
Dec 31 '18 at 20:26
|
show 2 more comments
2axI8,tVYHK,uBLfadhjMvfDi,OzE55
1
currDir.FullName + @"" + @"blank.txt" wouldnt that give you two on your path?. You shoud be using Path.Combine(path1,path2) to go aroudn merging paths and the "" that can be duplicated if both paths contain the ""
– npo
Dec 30 '18 at 20:48
Thanks for pointing out, as soon as i figure out how to use it i'll try to, but for now I'm concerned more about the thing that the way I implemented it works, but only for directories which are not deeper than 3rd folder.
– Raczy
Dec 30 '18 at 22:50