© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
45 replies
daveeska

❔ Failed reading a file

The code:

class Server
    {
        private string usrcLoc;
        private int totalUsrs;
        private void init()
        {
            string usercount = usrcLoc;
            if (File.Exists(usercount))
            { 
                totalUsrs = int.Parse(File.ReadAllText(usercount));
            }
            else
            {
                Console.WriteLine("oof");
                totalUsrs = 0;
            }
        }

        public Server()
        {
            usrcLoc = @"C:\temp\ChaTe\ChatList\usrcount.txt";
            totalUsrs = 0;
        }

class Server
    {
        private string usrcLoc;
        private int totalUsrs;
        private void init()
        {
            string usercount = usrcLoc;
            if (File.Exists(usercount))
            { 
                totalUsrs = int.Parse(File.ReadAllText(usercount));
            }
            else
            {
                Console.WriteLine("oof");
                totalUsrs = 0;
            }
        }

        public Server()
        {
            usrcLoc = @"C:\temp\ChaTe\ChatList\usrcount.txt";
            totalUsrs = 0;
        }

C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ Reading a file
C#CC# / help
2y ago
❔ Reading a WAV file
C#CC# / help
3y ago
❔ Reading from a JSON file
C#CC# / help
3y ago
❔ Reading file (.txt)
C#CC# / help
3y ago