Quantum123 Posted September 30, 2020 Posted September 30, 2020 Hey everyone, I encountered a problem which I was not able to find a solution to solve my issue. I want to use a JObject parsed from a .json file. I used FileStreams and StreamReaders for that and got the error "C# filestreams could not be used" on login on the client side. My code is: public static JObject GetClothData(Sex sex) { string plainText = string.Empty; using (FileStream fs = File.OpenRead($"Clothes{(sex == Sex.Male ? "M" : "F")}.json")) { using (StreamReader sw = new StreamReader(fs)) { plainText = sw.ReadToEnd(); sw.Close(); } fs.Close(); } return JObject.Parse(plainText); } Is there anything to do in advance to allow filestreams or are there any workarounds? (e.g. in JS I can require a json file) Thanks in advance! Tim.
Quantum123 Posted October 1, 2020 Author Posted October 1, 2020 Hey, seems like FileStreams are blocked on purpose - everyone who encounters it just use File.ReadAllText(PATH). Cheers.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now