Click here to Skip to main content
13,087,925 members (79,459 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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
Updated 19-Sep-12 2:19am
Chris Meech 19-Sep-12 7:54am
Any chance that File.WriteAllText might return an error message.
ryanb31 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 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
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170813.1 | Last Updated 19 Sep 2012
Copyright © CodeProject, 1999-2017
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