Can anybody help me,

I want to create a text file in Local Drive or File server using salesforce APEX class or VF Page.



You can't. Salesforce have no access to your local drive because it is an cloud-application.

What you can do: create a visualforce page and render it as a text file using an contentType attribute:


The user could then download a text file to the local drive manually.


You can refer the below link:


Sample Code:

Visualforce page:

<apex:page controller="Sample" sidebar="false" action="{!fetch}" contentType="text/plain/#emp.txt" cache="false">
Employee Number : {!emp.Name}
Employee Name : {!emp.Employee_Name__c}
City : {!emp.City__c}
Email : {!emp.Email__c}
Description : {!emp.Description__c}

Apex Controller:

public class Sample
    public String empId;
    public Employee__c emp {get;set;}

    public Sample()


    public void fetch()
        empId = Apexpages.currentpage().getparameters().get('eid');
        emp = [SELECT Name, Employee_Name__c, City__c, State__c, Email__c, Description__c FROM Employee__c WHERE ID =: empId];


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.