School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 308,424 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 3,243 people online right now. Registration is fast and FREE... Join Now!




File not found.

 

File not found.

antarr.byrd

11 Oct, 2009 - 12:06 PM
Post #1

D.I.C Head
**

Joined: 30 Aug, 2009
Posts: 64


My Contributions
Im trying to convert my program to mobile.
When ever it trys to access my text file @ C:\\English.txt it tells me that i need to verify location of file

MyConvert.cs
CODE

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.IO;

namespace SmartDeviceProject1
{
    class MyConvert
    {
        String path = "ENGLISH.txt";

        public String myToDigit(String word)
        {
            StringBuilder sb = new StringBuilder();

            foreach (char c in word.ToLower())
            {
                if (c == 'a' || c == 'b' || c == 'c')
                {
                    sb.Append("2");
                }
                else if (c == 'd' || c == 'e' || c == 'f')
                {
                    sb.Append("3");
                }
                else if (c == 'g' || c == 'h' || c == 'i')
                {
                    sb.Append("4");
                }
                else if (c == 'j' || c == 'k' || c == 'l')
                {
                    sb.Append("5");
                }
                else if (c == 'm' || c == 'n' || c == 'o')
                {
                    sb.Append("6");
                }
                else if (c == 'p' || c == 'q' || c == 'r' || c == 's')
                {
                    sb.Append("7");
                }
                else if (c == 't' || c == 'u' || c == 'v')
                {
                    sb.Append("8");
                }
                else if (c == 'w' || c == 'x' || c == 'y' || c == 'z')
                {
                    sb.Append("9");
                }
            }


            return sb.ToString();
        }

        public String Dictionary(String ffile)
        {
            String match = "no word found";

            using (StreamReader reader = new StreamReader(path))
            {
                StreamReader read = new StreamReader(path);
                StreamWriter write = new StreamWriter("out.txt", true);
                int k = 0;
                String[] dictionary = new String[read.ReadToEnd().Length];
                read.Close();
                ArrayList matches = new ArrayList();
                while ((dictionary[k] = reader.ReadLine()) != null)
                {
                    String sreader = dictionary[k].ToString();
                    String test = myToDigit(sreader);
                    for (int job = 0; job < ffile.Length; job++)
                    {

                        if (test == ffile.Substring(job))
                        {
                            match = sreader;
                            write.WriteLine(sreader);
                        }
                    }
                    k++;
                }
                read.Close();
                reader.Close();
                write.Close();
                return match;
            }
        }

        public void appendDictionary()
        {
        }


        public void chooseDictionary()
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = "Text Files|*.txt";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                path = dlg.FileName;
                MessageBox.Show(path);
            }
        }

        public void setEnglish()
        {
            path = "ENGLISH.txt";
        }
        public void setSpanish()
        {
            path = "SPANISH.txt";
        }
        public void setFrench()
        {
            path = "FRENCH.TXT";
        }
    }
}


Form1.cs
CODE



using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.IO;


namespace SmartDeviceProject1
{
    public partial class Form1 : Form
    {
        MyConvert convert = new MyConvert();
        StringBuilder joe = new StringBuilder();
        String number_input, out2;
        
        public Form1()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void button9_Click(object sender, EventArgs e)
        {
            joe.Append("1");
            textBox1.Text = joe.ToString();
        }

        private void button7_Click(object sender, EventArgs e)
        {
            joe.Append("3");
            textBox1.Text = joe.ToString();
        }

        private void button8_Click(object sender, EventArgs e)
        {
            joe.Append("2");
            textBox1.Text = joe.ToString();
        }

        private void button12_Click(object sender, EventArgs e)
        {
            joe.Append("4");
            textBox1.Text = joe.ToString();
        }

        private void button11_Click(object sender, EventArgs e)
        {
            joe.Append("5");
            textBox1.Text = joe.ToString();
        }

        private void button10_Click(object sender, EventArgs e)
        {
            joe.Append("6");
            textBox1.Text = joe.ToString();
        }

        private void button6_Click(object sender, EventArgs e)
        {
            joe.Append("7");
            textBox1.Text = joe.ToString();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            joe.Append("8");
            textBox1.Text = joe.ToString();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            joe.Append("9");
            textBox1.Text = joe.ToString();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            joe.Append("0");
            textBox1.Text = joe.ToString();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (joe.Length > 0)
            {
                joe.Remove((joe.Length - 1), 1);
                textBox1.Text = joe.ToString();
            }
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void button3_Click(object sender, EventArgs e)
        {
            number_input = textBox1.Text;
            out2 = convert.Dictionary(number_input);
            using (StreamReader box = new StreamReader("out.txt"))
            {
                StreamReader locked = new StreamReader("out.txt");
                int a = locked.ReadToEnd().Length;
                ArrayList dogma = new ArrayList();
                String[] boxer = new String[a];
                for (int cobra = 0; cobra < a; cobra++)
                {

                    dogma.Add(box.ReadLine());
                }
                boxer = dogma.ToArray(typeof(string)) as string[];
                textBox2.Text = boxer.ToString();
                box.Close();
                locked.Close();
                FileInfo jump = new FileInfo(@"out.txt");
                jump.Delete();
            }
        }


    }


    }



User is offlineProfile CardPM
+Quote Post


Ikonmx

RE: File Not Found.

12 Oct, 2009 - 07:54 AM
Post #2

New D.I.C Head
*

Joined: 19 Aug, 2009
Posts: 27



Thanked: 1 times
My Contributions
In compact framework, theres no relative path, so your program is looking for \\English.txt at the root of the filesystem.


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/24/09 01:36PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month