Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8735513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:04:40+00:00 2026-06-13T10:04:40+00:00

For my class on Web Services I am trying to create an EXTREMELY simple

  • 0

For my class on Web Services I am trying to create an EXTREMELY simple login system. I ham having a problem where createAccounts() keeps getting infinite times whenever checkCredentials is called. Any idea why?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.IO;

public class Service : IService
{
    static String path = @"PATH REMOVED";
    List<Account> accounts = new List<Account>();
    StreamWriter sw = null;

    private void createAccounts()
    {
        String data = File.ReadAllText(path);
        string[] data2 = data.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
        string[] temp;
        for (int i = 0; i < data2.Length; i++)
        {
            temp = data2[i].Split(',');
            if(!usernameExists(temp[0]) && temp[0] != "")
            {
                accounts.Add(new Account(temp[0],temp[1]));
            }
        }
    }

    public bool CreateAccount(String username, String password)
    {
        createAccounts();
        sw = File.AppendText(path);
        if (!usernameExists(username))
        {
            sw.WriteLine(username + "," + password + "\n");
            sw.Close();
            sw = null;
            return true;
        }
        else
        {
            sw.Close();
            sw = null;
            return false;
        }
    }

    public bool usernameExists(String username)
    {
        createAccounts();
        if(accounts.Exists(a => a.username == username))
            return true;
        else
            return false;
    }

    public bool CheckCredentials(String username, String password)
    {
        createAccounts();
        if (usernameExists(username))
        {
            if(accounts.Find(a => a.username == username).username == username && accounts.Find(a => a.username == username).password == password)
                return true;
            else
                return false;
        }
        else
            return false;

    }

}

class Account
{
    public String username;
    public String password;

    public Account(String u, String p)
    {
        username = u;
        password = p;
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:04:41+00:00Added an answer on June 13, 2026 at 10:04 am

    You have a loop between createAccounts and usernameExists. As long as data2.Length is non-zero you’ll loop endlessly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create this JSON string but having problem creating it. I'm getting
Using the following Webservice definition using aClientArgs as a complex type: [System.Web.Script.Services.ScriptService] public class
i'm trying to create an application which connects to internet and consume web services
I'm using Exchange web services, trying to create a calendar entry in another user's
Im trying to create a web services that takes some arguments in its constructor
I'm trying to create a simple AJAX & web service test (using C# .Net
I am trying to create a simple Android client for a web service I
I'm trying to build the proxy class for a web service using the wsdl
I want to use Services(WCF/RIA /Web) to take data from Entity Data Model class
I am trying to create a common service library shared between a WCF web

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.