DirectoryNotFoundException: Could not find a part of the path

Discussion and help for Easy Save 3
Post Reply
allocate
Posts: 2
Joined: Tue Jun 02, 2020 11:26 pm

DirectoryNotFoundException: Could not find a part of the path

Post by allocate »

I'm sure I did something stupid to make this happen because it was working fine up to this point.

Line that causes the problem:

Code: Select all

ES3.Save("screen", screen, sceneName + Path.DirectorySeparatorChar + "screen.json");
The error it produces:

Code: Select all

DirectoryNotFoundException: Could not find a part of the path "C:\Users\allocate\AppData\LocalLow\DefaultCompany\Creative Pixel 2D\potion-bottle\screen.json.tmp".
ES3Internal.ES3Stream.CreateStream (ES3Settings settings, ES3Internal.ES3FileMode fileMode) (at Assets/Plugins/Easy Save 3/Scripts/Streams/ES3Stream.cs:65)
ES3Writer.Create (ES3Settings settings, System.Boolean writeHeaderAndFooter, System.Boolean overwriteKeys, System.Boolean append) (at Assets/Plugins/Easy Save 3/Scripts/Writers/ES3Writer.cs:377)
ES3Writer.Create (ES3Settings settings) (at Assets/Plugins/Easy Save 3/Scripts/Writers/ES3Writer.cs:371)
ES3.Save[T] (System.String key, T value, ES3Settings settings) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:48)
ES3.Save[T] (System.String key, T value, System.String filePath, ES3Settings settings) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:29)
ParseImage+<SaveScene>d__27.MoveNext () (at Assets/Scripts/ParseImage.cs:188)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <23a7799da2e941b88c6db790c607d655>:0)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
StateButtons:Save() (at Assets/Scripts/StateButtons.cs:26)
UnityEngine.EventSystems.EventSystem:Update() (at C:/Program Files/Unity/Hub/Editor/2019.3.14f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:377)
Any ideas?
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: DirectoryNotFoundException: Could not find a part of the path

Post by Joel »

Hi there,

Unity always uses forward slashes, regardless of platform, so you should instead do:

Code: Select all

ES3.Save("screen", screen, sceneName + "/" + "screen.json");
All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
allocate
Posts: 2
Joined: Tue Jun 02, 2020 11:26 pm

Re: DirectoryNotFoundException: Could not find a part of the path

Post by allocate »

Unity always uses forward slashes, regardless of platform, so you should instead do:
Very interesting! So I found that it randomly stopped working because I had deleted the directory. When the directory exists Path.DirectorySeparatorChar works fine. When it doesn't, a forward slash is required. Weird.

Fixed though. Thanks for your help!
Post Reply