7
मुझे अपने एंड्रॉइड ऐप से .NET WCF में .doc फ़ाइल अपलोड करने में समस्या है। मैं फाइल भेजने में सक्षम हूं लेकिन यह डब्ल्यूसीएफ अंत में समर्थित नहीं है। यहाँ अपलोड करने के लिए मेरी विधि है:एंड्रॉइड से .NET WCF तक एमएस वर्ड फ़ाइलों को अपलोड करना?
protected void checkinmethod(String rid) throws Exception {
File SDCardRoot = Environment.getExternalStorageDirectory();
//create a new file, specifying the path, and the filename
//which we want to save the file as.
File file = new File(SDCardRoot, rid+".doc");
InputStream in = new FileInputStream(file);
byte[] bytearray=new byte[(int) file.length()];
int ab=0;
do
{
ab=in.read(bytearray, 0, bytearray.length);
} while(ab>0);
InputStream mystream= new ByteArrayInputStream(bytearray);
InputStreamEntity se=new InputStreamEntity(mystream, 10000);
HttpPost request = new HttpPost("http://10.66.52.247/tutorwcf/Service.svc/Service/updateMyDoc1");
request.setHeader("Accept", "application/json");
request.setHeader("Content-type", "application/msword");
request.setEntity(se);
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpResponse response = httpClient.execute(request);
HttpEntity responseEntity = response.getEntity();
// Read response data into buffer
char[] buffer = new char[(int)responseEntity.getContentLength()];
InputStream stream = responseEntity.getContent();
InputStreamReader reader = new InputStreamReader(stream);
reader.read(buffer);
stream.close();
statuss.setText(new String(buffer));
//
}
catch (Exception e) {
// TODO: handle exception
Log.e("hi", "exception is", e);
statuss.setText("exception");
}
}
यहाँ .net कोड है:
FileStream fileToupload = new FileStream("D:\\myfile.doc", FileMode.Create, FileAccess.Write);
byte[] bytearray = new byte[10000];
int bytesRead, totalBytesRead = 0;
do
{
bytesRead = mystream.Read(bytearray, 0, bytearray.Length);
totalBytesRead += bytesRead;
} while (bytesRead > 0);
fileToupload.Write(bytearray, 0, bytearray.Length);
fileToupload.Close();
fileToupload.Dispose();
return "success";
}
कृपया लिंक या कोड या किसी बात भेजें।
आप विचार नहीं है के बारे में यह इस सवाल को रैंक कृपया .. धन्यवाद
सही समस्या क्या है? जब आप कोड चलाते हैं तो क्या आपको कोई त्रुटि संदेश या अपवाद मिलता है? – Kangkan
महोदय, डब्ल्यूसीएफ अंत में मुझे एक शब्द फ़ाइल मिल रही है। जब मैं इसे खोलने की कोशिश करता हूं तो यह मुझे त्रुटि "त्रुटि पढ़ने" दिखाता है। लेकिन जब मैं इसे नोट पैड या शब्द पैड में खोलता हूं तो यह मुझे इस तरह के प्रतीक दिखाता है: ÐÏà¡ ± á एक्स «Ç3aZ ¢ ÒÂà, ° D0 j ~ è3ß¶Îbãí ~ i> ƒØÍ3¿ \' õ? ê/ç [ج ¶Géâ \ Ä! Y-Urk। –
अपने प्रश्न रैंकिंग? – Krishnabhadra