Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Error IOException Sharing violation on path
my problem in check audio StreamReader

What I have tried:

mute audio

 public Toggle mute;
    public Text lable;
    public GameObject camera;
if (mute.isOn == true)
        {

            camera.GetComponent<AudioListener>().enabled = false;
            lable.text = "Sound Off";
            File.WriteAllText((Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Pong/audio.data")), "0");
        }
        else if (mute.isOn == false)
        {
            camera.GetComponent<AudioListener>().enabled = true;
            lable.text = "Sound On";
            File.WriteAllText((Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Pong/audio.data")), "1");

        }


check audio

string line1;
       string file = (Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Pong/audio.data"));
       StreamReader s1 = new StreamReader(file);

       if ((line1 = s1.ReadLine()) == "0")
       {
           camera.GetComponent<AudioListener>().enabled = false;

       }
       else
       {
           camera.GetComponent<AudioListener>().enabled = true;

       }
Posted
Updated 11-Dec-19 5:02am

1 solution

You are trying to write to a file that is open for reading.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900