c# - want to access data from text box in the form which is in another solution in visual studio 2013? -


i have 2 solutions tranferservice , sender. tranferservice has wcf service , iishost host service. in sender solution have windows forms application. in form used button browse , select file, text box display selected file path, , button(send) transfer file through wcf service. unable access textbox value in transfer solution. shows"the name not exist in current context".
code transferservice

using system; using system.collections.generic; using system.linq; using system.runtime.serialization; using system.servicemodel; using system.text; namespace transferservice {  // note: can use "rename" command on "refactor" menu change class name "transferservice" in both code , config file together. public class transferservice : itransferservice {      public file downloaddocument()     {         file file = new file();         string path = txtselectfilepath.text;         file.content = system.io.file.readallbytes(@path);         //file.name = "imagingdevices.exe";          return file;     } } } 

i getting error on line

string path = txtselectfilepath.text; 

code form.cs

    using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms;  namespace sender { public partial class form1 : form {     public form1()     {         initializecomponent();     }      private void browse_click(object sender, eventargs e)     {                       if (openfiledialog1.showdialog() == dialogresult.ok)         {             txtselectfilepath.text = openfiledialog1.filename;          }      }      private void send_click(object sender, eventargs e)     {         transferservice.transferserviceclient client = new transferservice.transferserviceclient();         transferservice.file file = client.downloaddocument();         system.io.file.writeallbytes(@"c:\downloadedfiles\" + file.name, file.content);         messagebox.show(file.name + " downloaded");     }    } } 

code itransferservice.cs

using system; using system.collections.generic; using system.linq; using system.runtime.serialization; using system.servicemodel; using system.text;  namespace transferservice { // note: can use "rename" command on "refactor" menu change interface name "itransferservice" in both code , config file together. [servicecontract] public interface itransferservice {     [operationcontract]     file downloaddocument(); }  [datacontract] public class file {     [datamember]     public string name { get; set; }      [datamember]     public byte[] content { get; set; }  } } 

thanx lot in advance..........

then create constructor class receives path string this:

public class transferservice : itransferservice {      private string _path;     public transferservice(string path) {         _path  = path     }      public file downloaddocument()     {         file file = new file();         //string path = txtselectfilepath.text;         file.content = system.io.file.readallbytes(_path);         //file.name = "imagingdevices.exe";          return file;     } } 

and on form.cs

 transferservice.transferserviceclient client = new transferservice.transferserviceclient(txtselectfilepath.text); 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -