I am currently developing an nodeJS app. I use a simple C# program to create a text file. That file is like a token which helps me to continue the execution of nodeJS app.I have the following javascript code:
function take_tool() {
while(take_tool_flag == false) {
if(fs.existsSync('D:/flag.txt')) {
fs.writeFileSync('D:/input_robot.txt', '-1');
console.log('Robot is taking the tool!');
fs.unlinkSync('D:/flag.txt');
take_tool_flag = true;
}
}
}
function draw_table() {
while(draw_table_flag == false && take_tool_flag == true) {
if(fs.existsSync('D:/flag.txt')) {
fs.writeFileSync('D:/input_robot.txt', '-3');
console.log('Robot is drawing the table game!');
fs.unlinkSync('D:/flag.txt');
draw_table_flag = true;
}
}
}
function game() {
console.log("Game has started!");
fs.writeFileSync('D:/input_robot.txt', '-99');
take_tool();
draw_table();
}
game();
And this is the code for C# program:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
for (int i = 0; i <= 10; i++)
{
System.Threading.Thread.Sleep(10000);
Console.WriteLine("File created!");
File.Create(@"D:\flag.txt", 1024);
}
}
}
}
I run the nodeJS app with "node filename.js" and then it wait for flag.txt to be created. But when i run C# program i get the following error:
Any ideas? Node version: 6.9.2.
via Codrut Tapu
No comments:
Post a Comment