I have a dll file that for now uses a .txt file as input that is located in the debug folder of my application. I want to replace this .txt file with text as submitted inside of a textbox within my application.
I'm still new to MVVM and WPF, and managed to get the dll functions working. I am however struggling with replacing the .txt file with textbox input. If anyone could help me out or point me towards the right path that would be greatly appreciated.
For clarification I want the method to read Textdetail (the text inside the textbox) instead of the contents of the file.
Method and string names have been changed as I cant share too much.
Inside the class
public string Textdetail { get; set; }
[DllImport("Blabla.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
public static extern void Method1 (
string string1,
StringBuilder string2,
StringBuilder string3);
public static void Createtxt(object data, string fileName)
{
var stream = new FileStream(fileName, FileMode.OpenOrCreate);
using (StreamWriter writer = new StreamWriter(stream, Encoding.UTF8))
{
writer.Write(data);
writer.Close();
}
}
public static void ExecuteProject()
{
string file = "Dependendfile.txt";
int capacity = 1000000;
int maxCapacity = 999999999;
StringBuilder string1 = new StringBuilder(capacity, maxCapacity);
StringBuilder string2 = new StringBuilder(capacity, maxCapacity);
LogixConvertRungs(File.ReadAllText(file), string1, string2);
CreateTxt(string1.ToString(), "File1-" + "Demo"+ ".txt");
CreateTxt(string1.ToString(), "File2-" + "Demo"+ ".txt");
}
the xaml textbox text
<TextBox x:Name="txt_replacefilewithtextfromthis"
TextWrapping="Wrap"
AcceptsReturn="True"
FontFamily="Corsiva"
FontSize="11"
Text="{Binding Textdetail, Mode=TwoWay}"/>
What I have tried:
I've tried looking up multiple tutorials, but cant figure out how to do it. The application either ignores the textbox input or gives off different erros