Click here to Skip to main content
12,549,332 members (46,620 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# 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
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 | Mobile
Web02 | 2.8.161021.1 | Last Updated 19 Sep 2012
Copyright © CodeProject, 1999-2016
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