0
\$\begingroup\$

During my developing, I always spend much time to fill up my vertex array by coding every vertex information when I have to create some complex models. It's quite inconvenient. It's will be very helpful if there is a method which can load the whole vertex information by reading the related files. For instance, there is a vertex file with 78 vertex-information in it such as:

Vertex Count: 78

Data:

4 -0.5 -4 0.998008 0.998008 0 1 -0
-4 -0.5 4 0.001992 0.00199199 0 1 -0
4 -0.5 4 0.998008 0.00199199 0 1 -0
4 -0.5 -4 0.998008 0.998008 0 1 -0
-4 -0.5 -4 0.001992 0.998008 0 1 -0
-4 -0.5 4 0.001992 0.00199199 0 1 -0
4 1 4 0.187127 0.998008 0 0 -1
-4 -0.5 4 0.000374 0.00199199 0 0 -1
-4 1 4 0.187127 0.00199199 0 0 -1
4 -0.5 4 0.000374 0.998008 0 0 -1
-4 -0.5 4 0.000374 0.00199199 0 0 -1
4 1 4 0.187127 0.998008 0 0 -1
4 1 -4 0.187126 0.998008 -1 0 -0
4 -0.5 4 0.000373 0.00199199 -1 0 -0
4 1 4 0.187126 0.00199199 -1 0 -0
4 -0.5 -4 0.000373 0.998008 -1 0 -0
4 -0.5 4 0.000373 0.00199199 -1 0 -0
4 1 -4 0.187126 0.998008 -1 0 -0
-4 1 -4 0.000374 0.00199199 0 0 1
4 -0.5 -4 0.187127 0.998008 0 0 1
4 1 -4 0.000374 0.998008 0 0 1
-4 1 -4 0.000374 0.00199199 0 0 1
-4 -0.5 -4 0.187127 0.00199199 0 0 1
4 -0.5 -4 0.187127 0.998008 0 0 1
-4 1 4 0.187127 0.998008 1 0 -0
-4 -0.5 -4 0.000374 0.00199199 1 0 -0
-4 1 -4 0.187127 0.00199199 1 0 -0
-4 -0.5 4 0.000374 0.998008 1 0 -0
-4 -0.5 -4 0.000374 0.00199199 1 0 -0
-4 1 4 0.187127 0.998008 1 0 -0
-5 1 5 0.199602 0.00199199 -1 0 -0
-5 -1 -5 0.000398 0.998008 -1 0 -0
-5 -1 5 0.000398 0.00199199 -1 0 -0
-5 1 -5 0.199602 0.998008 -1 0 -0
-5 -1 -5 0.000398 0.998008 -1 0 -0
-5 1 5 0.199602 0.00199199 -1 0 -0
5 1 -5 0.199602 0.00199199 1 0 -0
5 -1 5 0.000398 0.998008 1 0 -0
5 -1 -5 0.000398 0.00199199 1 0 -0
5 1 5 0.199602 0.998008 1 0 -0
5 -1 5 0.000398 0.998008 1 0 -0
5 1 -5 0.199602 0.00199199 1 0 -0
-5 -1 5 0.199602 0.00199199 0 0 1
5 1 5 0.000398 0.998008 0 0 1
-5 1 5 0.000398 0.00199199 0 0 1
5 -1 5 0.199602 0.998008 0 0 1
5 1 5 0.000398 0.998008 0 0 1
-5 -1 5 0.199602 0.00199199 0 0 1
-5 1 5 0.001992 0.00199199 0 1 -0
-4 1 -4 0.101594 0.898406 0 1 -0
-5 1 -5 0.001992 0.998008 0 1 -0
-5 1 5 0.001992 0.00199199 0 1 -0
-4 1 4 0.101594 0.101594 0 1 -0
-4 1 -4 0.101594 0.898406 0 1 -0
-4 1 -4 0.101594 0.898406 0 1 -0
5 1 -5 0.998008 0.998008 0 1 -0
-5 1 -5 0.001992 0.998008 0 1 -0
4 1 -4 0.898406 0.898406 0 1 -0
5 1 -5 0.998008 0.998008 0 1 -0
-4 1 -4 0.101594 0.898406 0 1 -0
4 1 -4 0.898406 0.898406 0 1 -0
5 1 5 0.998008 0.00199199 0 1 -0
5 1 -5 0.998008 0.998008 0 1 -0
4 1 4 0.898406 0.101594 0 1 -0
5 1 5 0.998008 0.00199199 0 1 -0
4 1 -4 0.898406 0.898406 0 1 -0
4 1 4 0.898406 0.101594 0 1 -0
-5 1 5 0.001992 0.00199199 0 1 -0
5 1 5 0.998008 0.00199199 0 1 -0
-5 1 5 0.001992 0.00199199 0 1 -0
4 1 4 0.898406 0.101594 0 1 -0
-4 1 4 0.101594 0.101594 0 1 -0
-5 1 -5 0.199602 0.00199199 0 0 -1
5 -1 -5 0.000398 0.998008 0 0 -1
-5 -1 -5 0.000398 0.00199199 0 0 -1
5 1 -5 0.199602 0.998008 0 0 -1
5 -1 -5 0.000398 0.998008 0 0 -1
-5 1 -5 0.199602 0.00199199 0 0 -1

There are there information in each vertex, which are position, texture, normal. So how could I set my vertex array by reading this file instead of coding these 78 verteces in my program?

My code is such as:

verts = new PositionTextureNormalVertex[]
            {
                new PositionTextureNormalVertex(new Vector3(4.0f,-0.5f,-4.0f),new Vector2(0.998008f,0.998008f), new Vector3(0.0f,1.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(-4.0f,-0.5f,4.0f),new Vector2(0.001992f,0.00199199f), new Vector3(0.0f,1.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(4.0f,-0.5f,4.0f),new Vector2(0.998008f,0.00199199f), new Vector3(0.0f,1.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(4.0f,-0.5f,-4.0f),new Vector2(0.998008f,0.998008f),new Vector3(0.0f,1.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(-4.0f,-0.5f,-4.0f),new Vector2(0.001992f,0.998008f), new Vector3(0.0f,1.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(-4.0f,-0.5f,4.0f),new Vector2(0.001992f,0.00199199f), new Vector3(0.0f,1.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(4.0f,1.0f,4.0f),new Vector2(0.187127f,0.998008f),new Vector3(0.0f,0.0f,-1.0f)),
                new PositionTextureNormalVertex(new Vector3(-4.0f,-0.5f,4.0f),new Vector2(0.000374f,0.00199199f),new Vector3(0.0f,0.0f,-1.0f)),
                new PositionTextureNormalVertex(new Vector3(-4.0f,1.0f,4.0f),new Vector2(0.187127f,0.00199199f),new Vector3(0.0f,0.0f,-1.0f)),
                new PositionTextureNormalVertex(new Vector3(4.0f,-0.5f,4.0f),new Vector2(0.000374f,0.998008f),new Vector3(0.0f,0.0f,-1.0f)),
                new PositionTextureNormalVertex(new Vector3(-4.0f,-0.5f,4.0f),new Vector2(0.000374f,0.00199199f),new Vector3(0.0f,0.0f,-1.0f)),
                new PositionTextureNormalVertex(new Vector3(4.0f,1.0f,4.0f),new Vector2(0.187127f,0.998008f),new Vector3(0.0f,0.0f,-1.0f)),
                new PositionTextureNormalVertex(new Vector3(4.0f,1.0f,-4.0f),new Vector2(0.187126f,0.998008f),new Vector3(-1.0f,0.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(4.0f,-0.5f,4.0f),new Vector2(0.000373f,0.00199199f),new Vector3(-1.0f,0.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(4.0f,1.0f,4.0f),new Vector2(0.187126f,0.00199199f),new Vector3(-1.0f,0.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(4.0f,-0.5f,-4.0f),new Vector2(0.000373f, 0.998008f),new Vector3(-1.0f,0.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(4.0f,-0.5f,4.0f),new Vector2(0.000373f,0.00199199f),new Vector3(-1.0f,0.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(4.0f,1.0f,-4.0f),new Vector2(0.187126f,0.998008f),new Vector3(-1.0f,0.0f,0.0f)),

                new PositionTextureNormalVertex(new Vector3(-4.0f,1.0f,-4.0f),new Vector2(0.000374f,0.00199199f),new Vector3(0.0f,0.0f,1.0f)),
                new PositionTextureNormalVertex(new Vector3(4.0f,-0.5f,-4.0f),new Vector2(0.187127f,0.998008f),new Vector3(0.0f,0.0f,1.0f)),
                new PositionTextureNormalVertex(new Vector3(4.0f,1.0f,-4.0f),new Vector2(0.000374f,0.998008f),new Vector3(0.0f,0.0f,1.0f)),
                new PositionTextureNormalVertex(new Vector3(-4.0f,1.0f,-4.0f),new Vector2(0.000374f,0.00199199f),new Vector3(0.0f,0.0f,1.0f)),
                new PositionTextureNormalVertex(new Vector3(-4.0f,-0.5f,-4.0f),new Vector2(0.187127f,0.00199199f),new Vector3(0.0f,0.0f,1.0f)),
                new PositionTextureNormalVertex(new Vector3(4.0f,-0.5f,-4.0f),new Vector2(0.187127f,0.998008f),new Vector3(0.0f,0.0f,1.0f)),

                new PositionTextureNormalVertex(new Vector3(-4.0f,1.0f, 4.0f),new Vector2(0.187127f,0.998008f),new Vector3(1.0f,0.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(-4.0f,-0.5f,-4.0f),new Vector2(0.000374f,0.00199199f),new Vector3(1.0f,0.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(-4.0f,1.0f,-4.0f),new Vector2(0.187127f,0.00199199f),new Vector3(1.0f,0.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(-4.0f,-0.5f,4.0f),new Vector2(0.000374f,0.998008f),new Vector3(1.0f,0.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(-4.0f,-0.5f,-4.0f),new Vector2(0.000374f,0.00199199f),new Vector3(1.0f,0.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(-4.0f,1.0f, 4.0f),new Vector2(0.187127f,0.998008f),new Vector3(1.0f,0.0f,0.0f)),

                new PositionTextureNormalVertex(new Vector3(-5.0f,1.0f,5.0f),new Vector2(0.199602f,0.00199199f),new Vector3(-1.0f,0.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(-5.0f,-1.0f,-5.0f),new Vector2(0.000398f,0.998008f),new Vector3(-1.0f,0.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(-5.0f,-1.0f,5.0f),new Vector2(0.000398f,0.00199199f),new Vector3(-1.0f,0.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(-5.0f,1.0f,-5.0f),new Vector2(0.199602f,0.998008f),new Vector3(-1.0f,0.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(-5.0f,-1.0f,-5.0f),new Vector2(0.000398f,0.998008f),new Vector3(-1.0f,0.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(-5.0f,1.0f,5.0f),new Vector2(0.199602f,0.00199199f),new Vector3(-1.0f,0.0f,0.0f)),

                new PositionTextureNormalVertex(new Vector3(5.0f,1.0f,-5.0f),new Vector2(0.199602f,0.00199199f), new Vector3(1.0f,0.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(5.0f,-1.0f,5.0f),new Vector2(0.000398f,0.998008f), new Vector3(1.0f,0.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(5.0f,-1.0f,-5.0f),new Vector2(0.000398f,0.00199199f), new Vector3(1.0f,0.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(5.0f,1.0f,5.0f),new Vector2(0.199602f,0.998008f),new Vector3(1.0f,0.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(5.0f,-1.0f,5.0f),new Vector2(0.000398f,0.998008f), new Vector3(1.0f,0.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(5.0f,1.0f,-5.0f),new Vector2(0.199602f,0.00199199f), new Vector3(1.0f,0.0f,0.0f)),

                new PositionTextureNormalVertex(new Vector3(-5.0f,-1.0f,5.0f),new Vector2(0.199602f,0.00199199f),new Vector3(0.0f,0.0f,1.0f)),
                new PositionTextureNormalVertex(new Vector3(5.0f,1.0f,5.0f),new Vector2(0.000398f,0.998008f),new Vector3(0.0f,0.0f,1.0f)),
                new PositionTextureNormalVertex(new Vector3(-5.0f,1.0f,5.0f),new Vector2(0.000398f,0.00199199f),new Vector3(0.0f,0.0f,1.0f)),
                new PositionTextureNormalVertex(new Vector3(5.0f,-1.0f,5.0f),new Vector2(0.199602f,0.998008f),new Vector3(0.0f,0.0f,1.0f)),
                new PositionTextureNormalVertex(new Vector3(5.0f,1.0f,5.0f),new Vector2(0.000398f,0.998008f),new Vector3(0.0f,0.0f,1.0f)),
                new PositionTextureNormalVertex(new Vector3(-5.0f,-1.0f,5.0f),new Vector2(0.199602f,0.00199199f),new Vector3(0.0f,0.0f,1.0f)),

                new PositionTextureNormalVertex(new Vector3(-5.0f,1.0f,5.0f),new Vector2(0.001992f,0.00199199f),new Vector3(0.0f,1.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(-4.0f,1.0f,-4.0f),new Vector2(0.101594f,0.898406f),new Vector3(0.0f,1.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(-5.0f,1.0f,-5.0f),new Vector2(0.001992f,0.998008f),new Vector3(0.0f,1.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(-5.0f,1.0f,5.0f),new Vector2(0.001992f,0.00199199f),new Vector3(0.0f,1.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(-4.0f,1.0f,4.0f),new Vector2(0.101594f,0.101594f),new Vector3(0.0f,1.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(-4.0f,1.0f,-4.0f),new Vector2(0.101594f,0.898406f),new Vector3(0.0f,1.0f,0.0f)),

                new PositionTextureNormalVertex(new Vector3(-4.0f,1.0f,-4.0f),new Vector2(0.101594f,0.898406f),new Vector3(0.0f,1.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(5.0f,1.0f,-5.0f),new Vector2(0.998008f,0.998008f),new Vector3(0.0f,1.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(-5.0f,1.0f,-5.0f),new Vector2(0.001992f,0.998008f),new Vector3(0.0f,1.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(4.0f,1.0f,-4.0f),new Vector2(0.898406f,0.898406f),new Vector3(0.0f,1.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(5.0f,1.0f,-5.0f),new Vector2(0.998008f,0.998008f),new Vector3(0.0f,1.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(-4.0f,1.0f,-4.0f),new Vector2(0.101594f,0.898406f),new Vector3(0.0f,1.0f,0.0f)),

                new PositionTextureNormalVertex(new Vector3(4.0f,1.0f, -4.0f),new Vector2(0.898406f,0.898406f),new Vector3(0.0f,1.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(5.0f,1.0f,5.0f),new Vector2(0.998008f,0.00199199f),new Vector3(0.0f,1.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(5.0f,1.0f,-5.0f),new Vector2(0.998008f,0.998008f),new Vector3(0.0f,1.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(4.0f,1.0f,4.0f),new Vector2(0.898406f,0.101594f),new Vector3(0.0f,1.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(5.0f,1.0f,5.0f),new Vector2(0.998008f,0.00199199f),new Vector3(0.0f,1.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(4.0f,1.0f, -4.0f),new Vector2(0.898406f,0.898406f),new Vector3(0.0f,1.0f,0.0f)),

                new PositionTextureNormalVertex(new Vector3(4.0f,1.0f,4.0f),new Vector2(0.898406f,0.101594f),new Vector3(0.0f,1.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(-5.0f,1.0f,5.0f),new Vector2(0.001992f,0.00199199f),new Vector3(0.0f,1.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(5.0f,1.0f,5.0f),new Vector2(0.998008f,0.00199199f),new Vector3(0.0f,1.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(-5.0f,1.0f,5.0f),new Vector2(0.001992f,0.00199199f),new Vector3(0.0f,1.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(4.0f,1.0f,4.0f),new Vector2(0.898406f,0.101594f),new Vector3(0.0f,1.0f,0.0f)),
                new PositionTextureNormalVertex(new Vector3(-4.0f,1.0f,4.0f),new Vector2(0.101594f,0.101594f),new Vector3(0.0f,1.0f,0.0f)),

                new PositionTextureNormalVertex(new Vector3(-5.0f,1.0f,-5.0f),new Vector2(0.199602f,0.00199199f),new Vector3(0.0f,0.0f,-1.0f)),
                new PositionTextureNormalVertex(new Vector3(5.0f,-1.0f,-5.0f),new Vector2(0.000398f,0.998008f),new Vector3(0.0f,0.0f,-1.0f)),
                new PositionTextureNormalVertex(new Vector3(-5.0f,-1.0f,-5.0f),new Vector2(0.000398f,0.00199199f),new Vector3(0.0f,0.0f,-1.0f)),
                new PositionTextureNormalVertex(new Vector3(5.0f,1.0f,-5.0f),new Vector2(0.199602f,0.998008f),new Vector3(0.0f,0.0f,-1.0f)),
                new PositionTextureNormalVertex(new Vector3(5.0f,-1.0f,-5.0f),new Vector2(0.000398f,0.998008f),new Vector3(0.0f,0.0f,-1.0f)),
                new PositionTextureNormalVertex(new Vector3(-5.0f,1.0f,-5.0f),new Vector2(0.199602f,0.00199199f),new Vector3(0.0f,0.0f,-1.0f)),
}
\$\endgroup\$
  • \$\begingroup\$ Help us understand what part of this you need help with. Do you know how to open a file? And how to read text data from that file? And how to parse that text data to find the numbers you need? And how to convert those into numeric data? And store those numbers in a suitably-chosen containing structure/array/buffer that your rendering code can use? Only that last part begins to get vertex-specific; the rest is just usual file I/O. Which parts do you already know how to do? \$\endgroup\$ – DMGregory Feb 13 '18 at 4:36
  • \$\begingroup\$ Oh yes,What I really want to know is the last part you've prompted. Thanks for helping me to get clear my question. \$\endgroup\$ – tedyage Feb 13 '18 at 7:53
  • \$\begingroup\$ time to learn how file parsing works \$\endgroup\$ – ratchet freak Feb 13 '18 at 11:38
0
\$\begingroup\$

this is the wavefront obj file loader that will allow you to load your models into memory. You need to add this as a part of your project as another solution. using Blender, you can export your models to .OBJ format. This loader is for very static models only.

included is some old code which I used to load files in with. See below. You will need to adapt the code and fill in the spaces in your code. This is working with Sharpdx and my project. Formatting is broken.

  public bool LoadMeshFromOBJ(string a_filename, string a_filepath, D3D11.DeviceContext2 a_context, D3D11.Device3 a_device)
    {
        FileStream fileStream = null;
        try
        {
            int vertexIndexCount = 0;

            var objLoaderFactory = new ObjLoaderFactory();
            IObjLoader objLoader = objLoaderFactory.Create();

            if (!File.Exists(a_filepath + a_filename))
            {
                throw new Exception("Mesh not found: " + a_filepath + a_filename);
            }

            fileStream = new FileStream(a_filepath + a_filename, FileMode.Open);
            LoadResult result = objLoader.Load(fileStream, a_filepath);

            m_masterVertexList.Clear();
            m_indexList.Clear();
            m_indiceBased = false;

            m_assetFileName = a_filepath + a_filename;
            m_assetExtension = Path.GetExtension(a_filename);
            m_assetName = a_filename.Substring(0, a_filename.Length - Path.GetExtension(m_assetExtension).Length).ToUpper();
            VertexPointMaster vp;

            for (int GroupCount = 0; GroupCount < result.Groups.Count; GroupCount++)
            {
                int texture = GlobalStatics.RenderManager.TextureFactory.GetTextureIndexByMaterialName(result.Groups[GroupCount].Material.Name, TextureGroup.Asset, true, a_device, a_context);

                if (!m_textureList.ContainsKey(texture))
                    m_textureList.Add(texture, result.Groups[GroupCount].Material.Name);

                for (int faceCount = 0; faceCount < result.Groups[GroupCount].Faces.Count; faceCount++)
                {
                    var Face = result.Groups[GroupCount].Faces[faceCount];

                    for (int i = 0; i < Face.Count - 1; i+=2)
                    {


                        for (int j = 0; j < 3; j++)
                        {
                            var FaceVertex = Face[(i + j) % Face.Count];

                            int vertexindex = (FaceVertex.VertexIndex - 1);  // should not use shorts, may need to be improved
                            int TextureIndex = (FaceVertex.TextureIndex - 1);  // should not use shorts, may need to be improved
                            int VertexNormal = (FaceVertex.NormalIndex - 1);

                            vp = new VertexPointMaster();
                            vp.m_vertex.X = result.Vertices[vertexindex].X;
                            vp.m_vertex.Y = result.Vertices[vertexindex].Y;
                            vp.m_vertex.Z = result.Vertices[vertexindex].Z;

                            if (TextureIndex >= 0)


                                vp.SetTextureUV(result.Textures[TextureIndex].X, -result.Textures[TextureIndex].Y);

                            vp.m_normal = (new Vector3(result.Normals[VertexNormal].X, result.Normals[VertexNormal].Y, result.Normals[VertexNormal].Z));
                            vp.m_normal.Normalize();

                            vp.TexturePrimary = texture;
                            vp.TextureSecondary = 0;
                            vp.SetTextureBlend(1.0f);

                            m_masterVertexList.Add(vp);
                        }
                        //  vertexIndexCount = vertexIndexCount + Face.Count;
                        vertexIndexCount += 3;
                    }
                }
            }

            RewindMesh(false, a_context, a_device);

            CreateDefaultBufferList(m_masterVertexList, m_indexList);
            CreateD3DBufferFromData(a_device, a_context, false);

            m_boundingBox.RegenerateBoundingBoxExtents(m_masterVertexList);

            return true;
        }
        catch (Exception ex)
        {
            ErrorHandler.DoErrorHandling(ex, ErrorHandler.GetCurrentMethod(ex), Environment.StackTrace);

        }
        finally
        {
            fileStream.Close();
        }

        return false;
    }
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Sorry for not commenting your answer for such a long time, as I was in a big vacation. And then thank you for sharing this code and professional answer. I will try it later. \$\endgroup\$ – tedyage Feb 27 '18 at 1:14
  • \$\begingroup\$ Not a problem, we all got have a holiday :) ] \$\endgroup\$ – ErnieDingo Feb 27 '18 at 2:18

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.