Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

C# Convert DataTable to Json File using Newtonsoft.Json DLL

 // Install Newtonsoft.Json from nuget
//then add namespace
//Using NewtonSoft.Json;

public bool Write(string filePath, DataTable table, string fileName)
        {
            try
            {
                bool success = false;
                using (var file = File.CreateText(filePath + "" + fileName))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    serializer.Serialize(file, table);
                    success = true;
                }
                return success;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
 
PREVIOUS NEXT
Tagged: #Convert #DataTable #Json #File #DLL
ADD COMMENT
Topic
Name
2+1 =