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();
}
}
}
}