Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends,

C#
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.

regards
Posted
Updated 19-Sep-12 2:19am
v2
Comments
Chris Meech 19-Sep-12 7:54am    
Any chance that File.WriteAllText might return an error message.
ZurdoDev 19-Sep-12 9:00am    
It is likely a permissions issue.

1 solution

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.
 
Share this answer
 
Comments
Ahamed Azeem 20-Sep-12 14:16pm    
Dear,

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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900