Problem with path in FileStream

try {
FileStream fsr = new FileStream(Application.dataPath + @"\Resources\converted.uvtddir ", FileMode.Open, FileAccess.Read);
BinaryFormatter formatter = new BinaryFormatter();
Chapters = (IList)formatter.Deserialize(fsr);
fsr.Close();
}catch (Exception e){
Debug.Log(e.Message);
}

Hello, i have problem with path to file in resource. Everythink WORK excellent in unity editor, but when i build this on windows or android, throw error : Could not find a part of the path “C:.…”. I’m confused, please help.

You need to store the file as a text asset (with file extension “.bytes”) and load it with Resources.Load().

Anything in a /Resources folder will get pre-built into an Asset Bundle when you deploy (as opposed to a normal folder you can navigate to)

You can access the raw bytes by using textAsset.bytes, and with the byte you can make a memory stream that can be used in place of the file stream.

(Edit: Updated to include extra info from conversation with OP)

When built, does that path exist? Is the file there? If not, make that path, and put that file there.