Click here to Skip to main content
11,706,639 members (38,516 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C#4.0
Dear Friends,

File.WriteAllText(ev.FullPath, File.ReadAllText(ev.FullPath, Encoding.Default), Encoding.UTF8); 

This function works fine in my local machine but when i put the application in the server it reads the file but writing an empty string.

what could be the issue.

Posted 19-Sep-12 1:52am
Edited 19-Sep-12 2:19am
Chris Meech at 19-Sep-12 7:54am
Any chance that File.WriteAllText might return an error message.
ryanb31 at 19-Sep-12 9:00am
It is likely a permissions issue.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The chances are that the ReadAllText is failing, rather than the WriteAllText. Check the file path to make sure the file exists, and that the user the server process is logged in as has read access to the folder containing the file.
Ahamed Azeem at 20-Sep-12 14:16pm

The user has read and write permission on the folder, because my concept is listening to the folder and whenever xml file came in, it will parse the file and put it in the database.

It works but it has some arabic characters and it displays "?" mark instead of arabic characters, so I will have to change the encoding type to UTF 8, thats why I try reading the file and write it back with UTF 8.

And then the file will be sent for parsing. Without this line the file reading and parsing works fine, so there is no permission issue involved, I guess the problem in "Encoding.Default" statement, Expecting your valuable suggestions.

Thanking you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 202
1 Sergey Alexandrovich Kryukov 135
2 chainerlt 110
3 Mika Wendelius 80
4 ppolymorphe 71
0 OriginalGriff 9,190
1 Sergey Alexandrovich Kryukov 8,407
2 CPallini 5,189
3 Maciej Los 4,756
4 Mika Wendelius 3,686

Advertise | Privacy | Mobile
Web02 | 2.8.150819.1 | Last Updated 19 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100